Krypto for Upgrades

This commit is contained in:
He-Man 2019-03-01 23:07:20 +01:00
parent 7aea1f4ecd
commit 13f5d09b7e
2 changed files with 39 additions and 9 deletions

View File

@ -23,7 +23,7 @@
NOTHING
*/
//[[[cog import generate_private_arrays ]]]
private ["_buildingAllowed","_canUpgrade","_canUpgradePartCount","_config","_config2","_countdoors","_countgates","_doors","_gates","_jammer","_maxdoors","_maxgates","_missingCount","_missingParts","_nearestJammer","_ownedJammerExists","_part","_partCheck","_removedPartCount","_req","_return","_stability","_targeter","_upgrade","_upgradeParts","_upgrades","_upgradeto","_buildingJammerRange","_JammerConfig"];
private ["_buildingAllowed","_canUpgrade","_canUpgradePartCount","_config","_config2","_countdoors","_countgates","_doors","_gates","_jammer","_maxdoors","_maxgates","_missingCount","_missingParts","_nearestJammer","_ownedJammerExists","_part","_partCheck","_removedPartCount","_req","_return","_stability","_targeter","_upgrade","_upgradeParts","_upgrades","_upgradeto","_buildingJammerRange","_JammerConfig","_CryptoCosts"];
//[[[end]]]
params [
["_object",objNull,[objNull]],
@ -82,10 +82,17 @@ if (_object isKindOf "Constructions_static_F" || {(typeof _object) in (call EPOC
_canUpgrade = true;
_canUpgradePartCount = 0;
_missingParts = "Missing: ";
_CryptoCosts = 0;
{
_part = _x select 0;
_req = _x select 1;
_partCheck = {_x == _part} count (magazines player);
_partCheck = if (_part IsEqualTo "Krypto") then {
_CryptoCosts = _CryptoCosts + _req;
EPOCH_PlayerCrypto
}
else {
{_x == _part} count (magazines player)
};
if (_partCheck < _req) then {
_missingCount = _req - _partCheck;
@ -126,17 +133,23 @@ if (_object isKindOf "Constructions_static_F" || {(typeof _object) in (call EPOC
_removedPartCount = 0;
if (_canUpgrade) then {
{
for "_i" from 1 to (_x select 1) do {
if ((_x select 0) in (magazines player)) then {
player removeMagazine (_x select 0);
_removedPartCount = _removedPartCount + 1;
_x params ["_part","_req"];
if !(_part IsEqualTo "Krypto") then {
for "_i" from 1 to _req do {
if (_part in (magazines player)) then {
player removeMagazine _part;
_removedPartCount = _removedPartCount + 1;
};
};
}
else {
_removedPartCount = _removedPartCount + _req;
};
} forEach _upgradeParts;
if (_canUpgradePartCount == _removedPartCount) then {
// send to server for upgrade
[_object,player,Epoch_upgradeIndex,Epoch_personalToken] remoteExec ["EPOCH_server_upgradeBUILD",2];
[_object,player,Epoch_upgradeIndex,Epoch_personalToken,_CryptoCosts] remoteExec ["EPOCH_server_upgradeBUILD",2];
Epoch_upgradeIndex = nil;
_return = true;
["Upgraded", 5] call Epoch_message;

View File

@ -13,13 +13,30 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_bases/EPOCH_server_upgradeBUILD.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_cfgBaseBuilding","_class","_newObj","_objSlot","_objType","_upgrade","_upgrades"];
private ["_cfgBaseBuilding","_class","_newObj","_objSlot","_objType","_upgrade","_upgrades","_Skip"];
//[[[end]]]
params ["_object","_player",["_index",0],["_token","",[""]] ];
params ["_object","_player",["_index",0],["_token","",[""]],["_CryptoCosts",0]];
if (isNull _object) exitWith{};
if !([_player, _token] call EPOCH_server_getPToken) exitWith{};
_Skip = false;
if (_CryptoCosts > 0) then {
_cIndex = EPOCH_customVars find "Crypto";
_vars = _player getVariable["VARS", call EPOCH_defaultVars_SEPXVar];
_current_crypto = _vars select _cIndex;
if (_current_crypto < _CryptoCosts) Exitwith {
_Skip = true;
};
_playerCryptoLimit = EPOCH_customVarLimits select _cIndex;
_playerCryptoLimit params ["_playerCryptoLimitMax","_playerCryptoLimitMin"];
_current_crypto = ((_current_crypto - _CryptoCosts) min _playerCryptoLimitMax) max _playerCryptoLimitMin;
_current_crypto remoteExec ['EPOCH_effectCrypto',_player];
_vars set[_cIndex, _current_crypto];
_player setVariable["VARS", _vars];
};
if (_Skip) exitwith {};
_objSlot = _object getVariable["BUILD_SLOT", -1];
_cfgBaseBuilding = 'CfgBaseBuilding' call EPOCH_returnConfig;
if (_objSlot != -1) then {