Skip to content

Commit

Permalink
Added ability to configure maximum batteries and battery upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
tunbridgep committed Feb 19, 2021
1 parent 3064c97 commit f80aeb1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
Binary file removed sprite workspace/FLBLA0.xcf
Binary file not shown.
2 changes: 2 additions & 0 deletions src/CVARINFO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ server int flashlight_battery_max = 1575;
server int flashlight_battery_min_threshold = 315;
server int flashlight_battery_use_per_tic = 1;
server int flashlight_battery_charge_per_tic = 3;
server int flashlight_battery_recharge_max_amount = 30;
server int flashlight_battery_upgrade_max_amount = 30;

//map alteration
server int flashlight_darken_mode = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/LANGUAGE.enu
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ FLASHLIGHT_BATTERY_USE = "Battery Use Rate (tics)";
FLASHLIGHT_BATTERY_CHARGE = "Battery Charge Rate (tics)";
FLASHLIGHT_BATTERY_DESC1 = "Battery is required to use the flashlight.";
FLASHLIGHT_BATTERY_DESC2 = "Flashlight can not be reactivated below the minumum.";
FLASHLIGHT_BATTERY_RECHARGE_INVENTORY_MAX = "Maximum Batteries";
FLASHLIGHT_BATTERY_UPGRADE_INVENTORY_MAX = "Maximum Battery Upgrades";
FLASHLIGHT_BATTERY_INVENTORY_MAX_DESC = "The maximum number of batteries and battery upgrades the player can carry";

//Darken Modes and Level Alteration
FLASHLIGHT_DARKEN_MODE = "Light Alteration Mode";
Expand Down
3 changes: 3 additions & 0 deletions src/MENUDEF.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ OptionMenu "FlashlightGameplayOptions"
FlashlightSlider "$FLASHLIGHT_BATTERY_CHARGE", "flashlight_battery_charge_per_tic", 0,100,1,0,"flashlight_battery_mode","$FLASHLIGHT_MENU_NOOP"
StaticText "$FLASHLIGHT_BATTERY_DESC1"
StaticText "$FLASHLIGHT_BATTERY_DESC2"
ScaleSlider "$FLASHLIGHT_BATTERY_RECHARGE_INVENTORY_MAX", "flashlight_battery_recharge_max_amount", 0,100,1,"$FLASHLIGHT_UNLIMITED"
ScaleSlider "$FLASHLIGHT_BATTERY_UPGRADE_INVENTORY_MAX", "flashlight_battery_upgrade_max_amount", 0,100,1,"$FLASHLIGHT_UNLIMITED"
StaticText "$FLASHLIGHT_BATTERY_INVENTORY_MAX_DESC"
}

OptionMenu "FlashlightLightingOptions"
Expand Down
2 changes: 1 addition & 1 deletion src/zsc/Battery.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Battery : Inventory
updateFromCVars();
battery_level = GetMax();
}

protected int numBatteryRecharges()
{
int re;
Expand Down
16 changes: 14 additions & 2 deletions src/zsc/BatteryUpgrades.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class FlashlightBatteryUpgrade : Inventory
+COUNTITEM;
Inventory.PickupSound "misc/gettool" ;
Inventory.PickupMessage "$FLASHLIGHT_BATT_EXP_PICKUP";
Inventory.InterHubAmount 10;
Inventory.MaxAmount 10;
Inventory.InterHubAmount 999;
Inventory.MaxAmount 999;
Inventory.Amount 1;
Scale 0.4;
}
Expand All @@ -25,6 +25,12 @@ class FlashlightBatteryUpgrade : Inventory
CELP A -1;
Loop;
}

override bool CanPickup(Actor toucher)
{
bool allow = flashlight_battery_upgrade_max_amount <= 0 || toucher.CountInv("FlashlightBatteryUpgrade") < flashlight_battery_upgrade_max_amount;
return allow && super.CanPickup(toucher);
}
}

class FlashlightBatteryRecharge : FlashlightBatteryUpgrade
Expand All @@ -33,4 +39,10 @@ class FlashlightBatteryRecharge : FlashlightBatteryUpgrade
{
Inventory.PickupMessage "$FLASHLIGHT_BATT_PICKUP";
}

override bool CanPickup(Actor toucher)
{
bool allow = flashlight_battery_recharge_max_amount <= 0 || toucher.CountInv("FlashlightBatteryRecharge") < flashlight_battery_recharge_max_amount;
return allow && super.CanPickup(toucher);
}
}
4 changes: 2 additions & 2 deletions src/zsc/Flares.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Flare : CustomInventory
+INVENTORY.HUBPOWER;
+INVENTORY.PERSISTENTPOWER;
+DONTGIB;
Inventory.MaxAmount 9999;
Inventory.InterHubAmount 9999;
Inventory.MaxAmount 999;
Inventory.InterHubAmount 999;
Inventory.Icon "FLARINV";
Inventory.PickupMessage "You picked up a flare.";
}
Expand Down

0 comments on commit f80aeb1

Please sign in to comment.