red_ned

Exile Random loot in supply drop

19 posts in this topic

Hello Folks.  I'm new at ARMA scripting.  I've been learning a lot from the posts here; thanks!  I implemented red_ned's  ExileServer_system_event_supplyBox_start.sqf  and it worked great.  I then tried to modify it in order to add ExileMoney to the crates.  Below are code snippets from my exile_server_config\config.cpp and the  ExileServer_system_event_supplyBox_start.sqf  

Any suggestions as to why _box setVariable ["ExileMoney", _itemCount ,true]; doesn't trigger?

(The crates do fill as expected with the other items)

Spoiler

from Config.ccp:
    class ExpRare
        {
            items[] = 
            {
                {"ExileMoney", 50, 500},
                {"SatchelCharge_Remote_Mag", 0, 1},
                {"DemoCharge_Remote_Mag", 0, 1},
                {"IEDLandSmall_Remote_Mag", 0, 1}
            };
        };

from ExileServer_system_event_supplyBox_start:
    {
    _itemClassName = _x select 0;
    _itemCountMin  = _x select 1;                                                //added by [CiC]red_ned
    _itemCountMax  = _x select 2;                                                //added by [CiC]red_ned
    _itemCount = _itemCountMin + (round (random(_itemCountMax-_itemCountMin)));    //added by [CiC]red_ned

    if (_itemClassName IsEqualTo "ExileMoney") then  //<<<---Is this incorrect?
    {
        _box setVariable ["ExileMoney", _itemCount ,true];  //<<<---becuase this ever executes. 
    }
    else
    {
        for "_i" from 1 to _itemCount do 
        {
            [_box, _itemClassName] call ExileClient_util_containerCargo_add; //<<<---This coutinues to work as expected
        };
    };
}

 

Share this post


Link to post
Share on other sites

Posted (edited)

On ‎02‎/‎08‎/‎2018 at 5:02 AM, JR_Walker said:

Hello Folks.  I'm new at ARMA scripting.  I've been learning a lot from the posts here; thanks!  I implemented red_ned's  ExileServer_system_event_supplyBox_start.sqf  and it worked great.  I then tried to modify it in order to add ExileMoney to the crates.  Below are code snippets from my exile_server_config\config.cpp and the  ExileServer_system_event_supplyBox_start.sqf  

Any suggestions as to why _box setVariable ["ExileMoney", _itemCount ,true]; doesn't trigger?

(The crates do fill as expected with the other items)

  Reveal hidden contents

from Config.ccp:
    class ExpRare
        {
            items[] = 
            {
                {"ExileMoney", 50, 500},
                {"SatchelCharge_Remote_Mag", 0, 1},
                {"DemoCharge_Remote_Mag", 0, 1},
                {"IEDLandSmall_Remote_Mag", 0, 1}
            };
        };

from ExileServer_system_event_supplyBox_start:
    {
    _itemClassName = _x select 0;
    _itemCountMin  = _x select 1;                                                //added by [CiC]red_ned
    _itemCountMax  = _x select 2;                                                //added by [CiC]red_ned
    _itemCount = _itemCountMin + (round (random(_itemCountMax-_itemCountMin)));    //added by [CiC]red_ned

    if (_itemClassName IsEqualTo "ExileMoney") then  //<<<---Is this incorrect?
    {
        _box setVariable ["ExileMoney", _itemCount ,true];  //<<<---becuase this ever executes. 
    }
    else
    {
        for "_i" from 1 to _itemCount do 
        {
            [_box, _itemClassName] call ExileClient_util_containerCargo_add; //<<<---This coutinues to work as expected
        };
    };
}

 

ok its got to be outside the item loop -

*all edits are in each mission file itself, there is no addition to the server config file* e.g. ExileServer_system_event_supplyBox_start.sqf

in each mission

1. add into the private[] string  "_cash" // making sure you comma separate the items

2. add under the private line:

_cash = (1000 + round (random (1500)));       //this gives 1000 to 2500 cash so adjust to fit

3. add under forEach (getArray (_config >> "BoxTypes" >> _boxType >> "items"));

_box setVariable ["ExileMoney", _cash,true];

that should work ok so just 3 edits per mission file should do what you want - I like to define my variables at the top and use as close name code to my DMS missions as possible so its easier to find later

Edited by red_ned

Share this post


Link to post
Share on other sites
Advertisement

Thanks very much for taking the time to respond to my question @red_ned.

Unfortunately still no popcaps  :(  . The report file is showing no errors and the other loot items do populate the crate.  Below is the entirety of  the ExileServer_system_event_supplyBox_start.sqf based on your suggestions.  I'm certainly frustrated but not willing to give up on this yet; any additional suggestions would be very appreciated.

Thanks again, Walker

Spoiler

/**
 * ExileServer_system_event_supplyBox_start
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 * Slight edit to give min and max random possible loot in crate
 */
 
private["_airportPositions", "_config", "_markerTime", "_filteredAirportPositions", "_dropAltitude", "_dropRadius", "_boxType", "_airportPosition", "_position", "_marker", "_box", "_itemClassName", "_itemCount","_itemCountMax","_itemCountMin", "_i", "_supplySmoke", "_parachute", "_cash"];
_airportPositions = call ExileClient_util_world_getAllAirportPositions;
_config = configFile >> "CfgSettings" >> "Events" >> "SupplyBox";
_markerTime = getNumber (_config >> "markerTime");
_cash = 1000;
if (_airportPositions isEqualTo []) exitWith
{
    "The current map has no airports. Skipping supply box drop event." call ExileServer_util_log;
};
_filteredAirportPositions = [];
{
    if !([_x, 1000] call ExileClient_util_world_isTraderZoneInRange) then 
    {
        _filteredAirportPositions pushBack _x;
    };
}
forEach _airportPositions;
if (_filteredAirportPositions isEqualTo []) exitWith
{
    "The current map has airports, but they are too close to traders. Skipping supply box drop event." call ExileServer_util_log;
};
_config = configFile >> "CfgSettings" >> "Events" >> "SupplyBox";
_dropAltitude = getNumber (_config >> "dropAltitude");
_dropRadius = getNumber (_config >> "dropRadius");
_boxType = selectRandom (getArray (_config >> "types"));
_airportPosition = selectRandom _filteredAirportPositions;
_airportPosition set [2, 0];
_position = [_airportPosition, _dropRadius] call ExileClient_util_math_getRandomPositionInCircle;
_position set [2, _dropAltitude];
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 10 Minutes"]]] call ExileServer_system_network_send_broadcast;
_marker = createMarker [ format["ExileSupplyBox%1", diag_tickTime], _position];
_marker setMarkerType "ExileHeart";
uiSleep (60 * 1);
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 5 Minutes"]]] call ExileServer_system_network_send_broadcast;
uiSleep (60 * 1);
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 1 Minute"]]] call ExileServer_system_network_send_broadcast;
uiSleep (60 * 1);
_box = createVehicle ["Exile_Container_SupplyBox", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_box setPosATL _position;
_box setDir (random 360);
clearBackpackCargoGlobal _box;
clearWeaponCargoGlobal _box;
clearMagazineCargoGlobal _box;
clearItemCargoGlobal _box;
{
    _itemClassName = _x select 0;
    _itemCountMin  = _x select 1;                                                //added by [CiC]red_ned
    _itemCountMax  = _x select 2;                                                //added by [CiC]red_ned
    _itemCount = _itemCountMin + (round (random(_itemCountMax-_itemCountMin)));    //added by [CiC]red_ned
    for "_i" from 1 to _itemCount do 
    {
        [_box, _itemClassName] call ExileClient_util_containerCargo_add;
    };
}
forEach (getArray (_config >> "BoxTypes" >> _boxType >> "items"));
_box setVariable ["ExileMoney", _cash, true];
_supplySmoke = createVehicle ["Exile_Ammo_SmokeShellOrange", getPos _box, [], 0, "CAN_COLLIDE"];
_supplySmoke attachTo [_box, [0, 0, 0.5]];
_parachute = createVehicle ["O_Parachute_02_F", getPos _box, [], 0, "FLY"];
_parachute setPosATL _position;
_parachute setDir (getDir _box);
_box attachTo [_parachute, [0, 0, -1.2]];
waitUntil { ((getPos _box) select 2) < 1.5 };
detach _supplySmoke;
detach _box;
_parachute disableCollisionWith _box;
_box disableCollisionWith _parachute;
_position = getPos _box;
_position set [2, 0];
_box setPos _position;
_box setVelocity [0, 0, 0];
uiSleep (60 * _markerTime);
deleteMarker _marker;

 

Share this post


Link to post
Share on other sites
On ‎06‎/‎08‎/‎2018 at 3:49 PM, JR_Walker said:

Thanks very much for taking the time to respond to my question @red_ned.

Unfortunately still no popcaps  :(  . The report file is showing no errors and the other loot items do populate the crate.  Below is the entirety of  the ExileServer_system_event_supplyBox_start.sqf based on your suggestions.  I'm certainly frustrated but not willing to give up on this yet; any additional suggestions would be very appreciated.

Thanks again, Walker

  Hide contents

/**
 * ExileServer_system_event_supplyBox_start
 *
 * Exile Mod
 * www.exilemod.com
 * © 2015 Exile Mod Team
 *
 * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. 
 * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
 * Slight edit to give min and max random possible loot in crate
 */
 
private["_airportPositions", "_config", "_markerTime", "_filteredAirportPositions", "_dropAltitude", "_dropRadius", "_boxType", "_airportPosition", "_position", "_marker", "_box", "_itemClassName", "_itemCount","_itemCountMax","_itemCountMin", "_i", "_supplySmoke", "_parachute", "_cash"];
_airportPositions = call ExileClient_util_world_getAllAirportPositions;
_config = configFile >> "CfgSettings" >> "Events" >> "SupplyBox";
_markerTime = getNumber (_config >> "markerTime");
_cash = 1000;
if (_airportPositions isEqualTo []) exitWith
{
    "The current map has no airports. Skipping supply box drop event." call ExileServer_util_log;
};
_filteredAirportPositions = [];
{
    if !([_x, 1000] call ExileClient_util_world_isTraderZoneInRange) then 
    {
        _filteredAirportPositions pushBack _x;
    };
}
forEach _airportPositions;
if (_filteredAirportPositions isEqualTo []) exitWith
{
    "The current map has airports, but they are too close to traders. Skipping supply box drop event." call ExileServer_util_log;
};
_config = configFile >> "CfgSettings" >> "Events" >> "SupplyBox";
_dropAltitude = getNumber (_config >> "dropAltitude");
_dropRadius = getNumber (_config >> "dropRadius");
_boxType = selectRandom (getArray (_config >> "types"));
_airportPosition = selectRandom _filteredAirportPositions;
_airportPosition set [2, 0];
_position = [_airportPosition, _dropRadius] call ExileClient_util_math_getRandomPositionInCircle;
_position set [2, _dropAltitude];
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 10 Minutes"]]] call ExileServer_system_network_send_broadcast;
_marker = createMarker [ format["ExileSupplyBox%1", diag_tickTime], _position];
_marker setMarkerType "ExileHeart";
uiSleep (60 * 1);
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 5 Minutes"]]] call ExileServer_system_network_send_broadcast;
uiSleep (60 * 1);
["toastRequest", ["InfoTitleAndText", ["Supply drop incoming!", "ETA 1 Minute"]]] call ExileServer_system_network_send_broadcast;
uiSleep (60 * 1);
_box = createVehicle ["Exile_Container_SupplyBox", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_box setPosATL _position;
_box setDir (random 360);
clearBackpackCargoGlobal _box;
clearWeaponCargoGlobal _box;
clearMagazineCargoGlobal _box;
clearItemCargoGlobal _box;
{
    _itemClassName = _x select 0;
    _itemCountMin  = _x select 1;                                                //added by [CiC]red_ned
    _itemCountMax  = _x select 2;                                                //added by [CiC]red_ned
    _itemCount = _itemCountMin + (round (random(_itemCountMax-_itemCountMin)));    //added by [CiC]red_ned
    for "_i" from 1 to _itemCount do 
    {
        [_box, _itemClassName] call ExileClient_util_containerCargo_add;
    };
}
forEach (getArray (_config >> "BoxTypes" >> _boxType >> "items"));
_box setVariable ["ExileMoney", _cash, true];
_supplySmoke = createVehicle ["Exile_Ammo_SmokeShellOrange", getPos _box, [], 0, "CAN_COLLIDE"];
_supplySmoke attachTo [_box, [0, 0, 0.5]];
_parachute = createVehicle ["O_Parachute_02_F", getPos _box, [], 0, "FLY"];
_parachute setPosATL _position;
_parachute setDir (getDir _box);
_box attachTo [_parachute, [0, 0, -1.2]];
waitUntil { ((getPos _box) select 2) < 1.5 };
detach _supplySmoke;
detach _box;
_parachute disableCollisionWith _box;
_box disableCollisionWith _parachute;
_position = getPos _box;
_position set [2, 0];
_box setPos _position;
_box setVelocity [0, 0, 0];
uiSleep (60 * _markerTime);
deleteMarker _marker;

 

the only thing I can think of is that for some reason when _box is in the air it wont take the tabs, try moving _box setVariable ["ExileMoney", _cash, true]; to juat before the uiSleep line as by this point it has landed and lost the parachute.

If this doesn't work then it needs some other function call in order to add in the cash which I would have to look up but I hope this is the simple fix

Share this post


Link to post
Share on other sites

Posted (edited)

@JR_Walker

You missed the brackets in the code that @red_ned gave you.

_cash = (1000 + round (random (1500)));       //this gives 1000 to 2500 cash so adjust to fit


you put _cash = 1000;

I use this line when the box is created which works fine:

 

_box setVariable ["ExileMoney", (1500 + round (random (3000))),true];

Add it to

ExileServer_system_event_ikea_start.sqf

ExileServer_system_event_militarydrop_start.sqf

ExileServer_system_event_MoneyDrop_start.sqf

ExileServer_system_event_weed_start.sqf


After this:

 

_position set [2, 0];
_box setPos _position;
_box setVelocity [0, 0, 0];

 

@red_ned Thanks for sharing the loot drops, I like them having random items. cheers

Edited by aussie battler
1 person likes this

Share this post


Link to post
Share on other sites
9 hours ago, aussie battler said:

@JR_Walker

You missed the brackets in the code that @red_ned gave you.


_cash = (1000 + round (random (1500)));       //this gives 1000 to 2500 cash so adjust to fit


you put _cash = 1000;

I use this line when the box is created which works fine:

 


_box setVariable ["ExileMoney", (1500 + round (random (3000))),true];

Add it to

ExileServer_system_event_ikea_start.sqf

ExileServer_system_event_militarydrop_start.sqf

ExileServer_system_event_MoneyDrop_start.sqf

ExileServer_system_event_weed_start.sqf


After this:

 


_position set [2, 0];
_box setPos _position;
_box setVelocity [0, 0, 0];

 

@red_ned Thanks for sharing the loot drops, I like them having random items. cheers

I just tend to stick to my same variable calls as I script all my stuff to be easy for me to remember wtf I did!

I did think that the cash may be affected by paradrop hence why I think I suggested to put it where you suggest which is good as I'm not a stupid as I thought I was :)

nice to see stuff being used, I do try to think of new variations of stuff but sometimes I just run out of ideas

1 person likes this

Share this post


Link to post
Share on other sites

Thanks very much folks!  

It turns out that what @red_ned initially suggested worked just fine.  Perhaps I either failed to re-pack the pbo or when I tried to re-pack, the pbo was locked; my apologies.  At any rate it’s working now.  I will include it in those other scripts as you suggested @aussie battleras I add them to my server.

Thanks again!

1 person likes this

Share this post


Link to post
Share on other sites
10 hours ago, JR_Walker said:

Thanks very much folks!  

It turns out that what @red_ned initially suggested worked just fine.  Perhaps I either failed to re-pack the pbo or when I tried to re-pack, the pbo was locked; my apologies.  At any rate it’s working now.  I will include it in those other scripts as you suggested @aussie battleras I add them to my server.

Thanks again!

I just noticed my code was missing a space -> _boxsetvariable should have been _box setvariable

I have adjusted my code in the post to keep a record.

glad we could help

1 person likes this

Share this post


Link to post
Share on other sites
On ‎12‎/‎08‎/‎2018 at 2:53 AM, JR_Walker said:

Thanks very much folks!  

It turns out that what @red_ned initially suggested worked just fine.  Perhaps I either failed to re-pack the pbo or when I tried to re-pack, the pbo was locked; my apologies.  At any rate it’s working now.  I will include it in those other scripts as you suggested @aussie battleras I add them to my server.

Thanks again!

just cus you tweaked my imagination:

https://github.com/redned70/CodeAddons/tree/master/4TypesOfSideEvents

added in a cash only drop, pretty easy to install just like the others - 2 tweaks to server config, 1 tweak in fnc_ file, add file in server pbo and adjust _cash in SQF for whatever amount you want it to drop.

Made it a green circle with same settings as the ikea/military drop by @GolovaRaoul

I may tweak the crate but left it like others for now, marker circle is Green for this one.

Edited by red_ned
1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.