diff --git a/DXRFixes/DeusEx/Classes/Carcass.uc b/DXRFixes/DeusEx/Classes/Carcass.uc index 347374920..0415e8f26 100644 --- a/DXRFixes/DeusEx/Classes/Carcass.uc +++ b/DXRFixes/DeusEx/Classes/Carcass.uc @@ -257,11 +257,13 @@ function Frob(Actor Frobber, Inventory frobWith) function bool TryLootItem(DeusExPlayer player, Inventory item) { local DeusExPickup invItem; - local int itemCount, newAmmoAmmout, ammoAddedAmount; + local int itemCount, newAmmoAmmout, ammoAddedAmount, action; local Weapon weap; local Ammo playerAmmo; - if (class'DXRLoadouts'.static.IsRefused(item.class)) { + action = class'DXRLoadouts'.static.GetLootAction(item.class); + + if (action == 1) { // drop weap = Weapon(item); if (weap != None && weap.AmmoName != class'AmmoNone') { playerAmmo = Ammo(player.FindInventoryType(weap.AmmoName)); @@ -281,6 +283,13 @@ function bool TryLootItem(DeusExPlayer player, Inventory item) return true; } + if (action == 2 && Human(player).ConsumableWouldHelp(item) && DeusExPickup(item) != None) { // consume + DeleteInventory(item); + DeusExRootWindow(player.rootWindow).hud.receivedItems.AddItem(item, 1); + Human(player).InstantlyUseItem(DeusExPickup(item)); + return true; + } + if (item.IsA('NanoKey')) { player.PickupNanoKey(NanoKey(item)); diff --git a/DXRModules/DeusEx/Classes/DXRLoadouts.uc b/DXRModules/DeusEx/Classes/DXRLoadouts.uc index e308580af..5ccf5fcf0 100644 --- a/DXRModules/DeusEx/Classes/DXRLoadouts.uc +++ b/DXRModules/DeusEx/Classes/DXRLoadouts.uc @@ -478,10 +478,11 @@ simulated function PlayerLogin(#var(PlayerPawn) p) RandoStartingEquipment(p, false); #ifdef injections - class'MenuChoice_RefuseUseless'.static.SetRefusals(); - class'MenuChoice_RefuseFoodDrink'.static.SetRefusals(); - class'MenuChoice_RefuseMelee'.static.SetRefusals(); - class'MenuChoice_RefuseMisc'.static.SetRefusals(); + class'MenuChoice_LootActionUseless'.static.SetActions(); + class'MenuChoice_LootActionFoodSoda'.static.SetActions(); + class'MenuChoice_LootActionAlcohol'.static.SetActions(); + class'MenuChoice_LootActionMelee'.static.SetActions(); + class'MenuChoice_LootActionMisc'.static.SetActions(); #endif } @@ -696,53 +697,45 @@ function SpawnItems() reducer.Timer(); } -static function bool IsRefused(class type, optional out int strIdx) -{ - local DataStorage datastorage; - local string refusals; - - datastorage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); - refusals = datastorage.GetConfigKey("item_refusals"); - if(refusals == "") { - return false; +static function int GetLootAction( + class itemClass, + optional DataStorage storage, + optional out string lootActions, + optional out int strIdx +) { + if (storage == None) + storage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); + + lootActions = storage.GetConfigKey("loot_actions"); + strIdx = InStr(lootActions, "," $ itemClass.name $ "="); + if (strIdx != -1) { + return Int(Mid(lootActions, strIdx + Len(itemClass.name) + 2, 1)); } - strIdx = InStr(refusals, "," $ type.name $ ","); - return strIdx != -1; + return 0; } -static function UnsetRefuseItem(class type) +static function SetLootAction(class itemClass, int action, optional DataStorage storage) { - local DataStorage datastorage; - local string refusals, leftPart, rightPart; + local string lootActions, leftPart, rightPart; local int strIdx; - if (!IsRefused(type, strIdx)) - return; - - datastorage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); - refusals = datastorage.GetConfigKey("item_refusals"); - leftPart = Left(refusals, strIdx); - rightPart = Right(refusals, Len(refusals) - (strIdx + Len(type.name) + 1)); - refusals = leftPart $ rightPart; - - datastorage.SetConfig("item_refusals", refusals, 3600*24*366); -} - -static function SetRefuseItem(class type) -{ - local DataStorage datastorage; - local string refusals; - - if (IsRefused(type)) + if (storage == None) { + storage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); + } + if (GetLootAction(itemClass, storage, lootActions, strIdx) == action) { return; + } - datastorage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); - refusals = datastorage.GetConfigKey("item_refusals"); - - if (refusals == "") refusals = ","; - refusals = refusals $ type.name $ ","; - - datastorage.SetConfig("item_refusals", refusals, 3600*24*366); + if (lootActions == "") { + lootActions = "," $ itemClass.name $ "=" $ action $ ","; + } else if (strIdx == -1) { + lootActions = lootActions $ itemClass.name $ "=" $ action $ ","; + } else { + leftPart = Left(lootActions, strIdx + Len(itemClass.name) + 2); + rightPart = Mid(lootActions, strIdx + Len(itemClass.name) + 3); + lootActions = leftPart $ action $ rightPart; + } + storage.SetConfig("loot_actions", lootActions, 3600*24*366); } function RunTests() diff --git a/DXRVanilla/DeusEx/Classes/PersonaScreenInventory.uc b/DXRVanilla/DeusEx/Classes/PersonaScreenInventory.uc index 5d3bf5b1d..0ce8b4d5a 100644 --- a/DXRVanilla/DeusEx/Classes/PersonaScreenInventory.uc +++ b/DXRVanilla/DeusEx/Classes/PersonaScreenInventory.uc @@ -179,10 +179,17 @@ function EnableButtons() inv = Inventory(selectedItem.GetClientObject()); if (inv != None) { - if (class'DXRLoadouts'.static.IsRefused(inv.class)) { - btnRefusal.SetButtonText(AcceptLabel); - } else { - btnRefusal.SetButtonText(RefuseLabel); + switch (class'DXRLoadouts'.static.GetLootAction(inv.class)) { + case 0: + btnRefusal.SetButtonText(RefuseLabel); + break; + case 1: + btnRefusal.SetButtonText(AcceptLabel); + break; + case 2: + btnRefusal.SetButtonText(RefuseLabel); + btnRefusal.DisableWindow(); + break; } if (NanoKeyRing(inv) != None) { @@ -240,9 +247,9 @@ function UnsetRefuseItem() local Inventory item; item = Inventory(selectedItem.GetClientObject()); - if(item == None) return; + if (item == None) return; - class'DXRLoadouts'.static.UnsetRefuseItem(item.class); + class'DXRLoadouts'.static.SetLootAction(item.class, 0); btnRefusal.SetButtonText(RefuseLabel); player.ClientMessage(item.ItemName $ " set as not trash."); } @@ -254,9 +261,9 @@ function SetRefuseItem() local Vector dropVect; item = Inventory(selectedItem.GetClientObject()); - if(item == None) return; + if (item == None) return; - class'DXRLoadouts'.static.SetRefuseItem(item.class); + class'DXRLoadouts'.static.SetLootAction(item.class, 1); if (Pickup(item) == None) { DropSelectedItem(); diff --git a/DXRVanilla/DeusEx/Classes/Player.uc b/DXRVanilla/DeusEx/Classes/Player.uc index 583da2c6f..d3ef73cc8 100644 --- a/DXRVanilla/DeusEx/Classes/Player.uc +++ b/DXRVanilla/DeusEx/Classes/Player.uc @@ -532,34 +532,42 @@ function bool CanInstantLeftClick(DeusExPickup item) exec function ParseLeftClick() { local DeusExPickup item; - local Actor A; - local int i; Super.ParseLeftClick(); item = DeusExPickup(FrobTarget); if (item != None && CanInstantLeftClick(item)) { - foreach item.BasedActors(class'Actor', A) - A.SetBase(None); - // So that any effects get applied to you - item.SetOwner(self); - item.SetBase(self); - // add to the player's inventory, so ChargedPickups travel across maps - item.BecomeItem(); - item.bDisplayableInv = false; - item.Inventory = Inventory; - Inventory = item; - if(FireExtinguisher(item) != None) { - // this was buggy with multiple, but it doesn't make sense and wouldn't be useful to use multiple at once anyways - item.NumCopies = 1; - } - for(i=item.NumCopies; i > 0; i--) { - item.Activate(); - } + InstantlyUseItem(item); FrobTarget = None; } } +function InstantlyUseItem(DeusExPickup item) +{ + local Actor A; + local int i; + + if(item == None) return; + + foreach item.BasedActors(class'Actor', A) + A.SetBase(None); + // So that any effects get applied to you + item.SetOwner(self); + item.SetBase(self); + // add to the player's inventory, so ChargedPickups travel across maps + item.BecomeItem(); + item.bDisplayableInv = false; + item.Inventory = Inventory; + Inventory = item; + if(FireExtinguisher(item) != None) { + // this was buggy with multiple, but it doesn't make sense and wouldn't be useful to use multiple at once anyways + item.NumCopies = 1; + } + for(i=item.NumCopies; i > 0; i--) { + item.Activate(); + } +} + exec function ParseRightClick() { local bool handled; @@ -1682,23 +1690,45 @@ exec function PlayerRot() ClientMessage("Player rotation: (" $ Rotation.pitch $ ", " $ Rotation.yaw $ ", " $ Rotation.roll $ ")"); } -exec function ShowRefused() +exec function LootActions() { - local string refusals, msg; + local string lootActions, msg; local int idx; - refusals = class'DataStorage'.static.GetObj(GetDXR()).GetConfigKey("item_refusals"); + lootActions = class'DataStorage'.static.GetObj(GetDXR()).GetConfigKey("loot_actions"); // basically just adds a space after every comma - while (Len(refusals) > 1) { - refusals = Right(refusals, Len(refusals) - 1); - idx = InStr(refusals, ","); - msg = msg $ Left(refusals, idx) $ ", "; - refusals = Right(refusals, Len(refusals) - idx); + lootActions = Mid(lootActions, 1); + while (lootActions != "") { + idx = InStr(lootActions, ","); + msg = msg $ Left(lootActions, idx) $ ", "; + lootActions = Mid(lootActions, idx + 1); } msg = Left(msg, Len(msg) - 2); - ClientMessage("Refused items: " $ msg); + ClientMessage("Loot actions: " $ msg); +} + +function bool ConsumableWouldHelp(Inventory item) { + if (health < default.health) { + if (MedKit(item) != None || SoyFood(item) != None || Candybar(item) != None || Sodacan(item) != None) { + return true; + } + if (HealingItem(item) != None && HealingItem(item).health > 0) { + return true; + } + } + + if (energy < default.energy) { + if (BioElectricCell(item) != None) { + return true; + } + if (HealingItem(item) != None && HealingItem(item).energy > 0) { + return true; + } + } + + return false; } diff --git a/GUI/DeusEx/Classes/MenuChoice_ItemRefusal.uc b/GUI/DeusEx/Classes/MenuChoice_ItemRefusal.uc deleted file mode 100644 index f4a063465..000000000 --- a/GUI/DeusEx/Classes/MenuChoice_ItemRefusal.uc +++ /dev/null @@ -1,26 +0,0 @@ -class MenuChoice_ItemRefusal extends DXRMenuUIChoiceBool; -#compileif injections - -var class refusedItems[6]; - -static function SetRefusals() -{ - local int i; - local class itemClass; - - for (i = 0; i < ArrayCount(default.refusedItems); i++) { - itemClass = default.refusedItems[i]; - if (itemClass == None) continue; - - if (default.enabled) - class'DXRLoadouts'.static.SetRefuseItem(itemClass); - else - class'DXRLoadouts'.static.UnsetRefuseItem(itemClass); - } -} - -function SaveSetting() -{ - Super.SaveSetting(); - SetRefusals(); -} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootAction.uc b/GUI/DeusEx/Classes/MenuChoice_LootAction.uc new file mode 100644 index 000000000..485fa6c58 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootAction.uc @@ -0,0 +1,33 @@ +class MenuChoice_LootAction extends DXRMenuUIChoiceInt; +#compileif injections + +var class itemClasses[5]; + +static function SetActions() +{ + local class itemClass; + local DataStorage storage; + local int i; + + storage = class'DataStorage'.static.GetObj(class'DXRando'.default.dxr); + for (i = 0; i < ArrayCount(default.itemClasses); i++) { + itemClass = default.itemClasses[i]; + if (itemClass == None) + continue; + class'DXRLoadouts'.static.SetLootAction(itemClass, default.value, storage); + } +} + +function SaveSetting() +{ + Super.SaveSetting(); + SetActions(); +} + +defaultproperties +{ + value=0 + defaultvalue=0 + enumText(0)="Pick Up" + enumText(1)="Drop" +} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootActionAlcohol.uc b/GUI/DeusEx/Classes/MenuChoice_LootActionAlcohol.uc new file mode 100644 index 000000000..46ca74ea4 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootActionAlcohol.uc @@ -0,0 +1,13 @@ +class MenuChoice_LootActionAlcohol extends MenuChoice_LootAction; +#compileif injections + +defaultproperties +{ + HelpText="Should alcohol be included in the list of Junk items that get dropped when looting a body, or get consumed automatically?" + actionText="Alcohol" + + itemClasses(0)=class'Liquor40oz' + itemClasses(1)=class'LiquorBottle' + itemClasses(2)=class'WineBottle' + enumText(2)="Consume" +} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootActionFoodSoda.uc b/GUI/DeusEx/Classes/MenuChoice_LootActionFoodSoda.uc new file mode 100644 index 000000000..756445b91 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootActionFoodSoda.uc @@ -0,0 +1,13 @@ +class MenuChoice_LootActionFoodSoda extends MenuChoice_LootAction; +#compileif injections + +defaultproperties +{ + HelpText="Should food and soda be included in the list of Junk items that get dropped when looting a body, or get consumed automatically?" + actionText="Food and Soda" + + itemClasses(0)=class'SoyFood' + itemClasses(1)=class'Candybar' + itemClasses(2)=class'Sodacan' + enumText(2)="Consume" +} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootActionMelee.uc b/GUI/DeusEx/Classes/MenuChoice_LootActionMelee.uc new file mode 100644 index 000000000..44897fed5 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootActionMelee.uc @@ -0,0 +1,16 @@ +class MenuChoice_LootActionMelee extends MenuChoice_LootAction; +#compileif injections + +defaultproperties +{ + value=1 + defaultvalue=1 + HelpText="Should melee weapons be included in the list of Junk items that get dropped when looting a body?" + actionText="Melee Weapons" + + itemClasses(0)=class'WeaponCombatKnife' + itemClasses(1)=class'WeaponCrowbar' + itemClasses(2)=class'WeaponSword' + itemClasses(3)=class'WeaponNanoSword' + itemClasses(4)=class'WeaponBaton' +} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootActionMisc.uc b/GUI/DeusEx/Classes/MenuChoice_LootActionMisc.uc new file mode 100644 index 000000000..c5b0a1be7 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootActionMisc.uc @@ -0,0 +1,13 @@ +class MenuChoice_LootActionMisc extends MenuChoice_LootAction; +#compileif injections + +defaultproperties +{ + HelpText="Should rebreathers, tech goggles, binoculars and flares be included in the list of Junk items that get dropped when looting a body?" + actionText="Miscellaneous" + + itemClasses(0)=class'Rebreather' + itemClasses(1)=class'TechGoggles' + itemClasses(2)=class'Binoculars' + itemClasses(3)=class'Flare' +} diff --git a/GUI/DeusEx/Classes/MenuChoice_LootActionUseless.uc b/GUI/DeusEx/Classes/MenuChoice_LootActionUseless.uc new file mode 100644 index 000000000..b75db9250 --- /dev/null +++ b/GUI/DeusEx/Classes/MenuChoice_LootActionUseless.uc @@ -0,0 +1,13 @@ +class MenuChoice_LootActionUseless extends MenuChoice_LootAction; +#compileif injections + +defaultproperties +{ + value=1 + defaultvalue=1 + HelpText="Should cigarettes and zyme be included in the list of Junk items that get dropped when looting a body?" + actionText="Cigarettes and Zyme" + + itemClasses(0)=class'Cigarettes' + itemClasses(1)=class'VialCrack' +} diff --git a/GUI/DeusEx/Classes/MenuChoice_RefuseFoodDrink.uc b/GUI/DeusEx/Classes/MenuChoice_RefuseFoodDrink.uc deleted file mode 100644 index 94dfd85ef..000000000 --- a/GUI/DeusEx/Classes/MenuChoice_RefuseFoodDrink.uc +++ /dev/null @@ -1,19 +0,0 @@ -class MenuChoice_RefuseFoodDrink extends MenuChoice_ItemRefusal; -#compileif injections - -defaultproperties -{ - enabled=False - defaultvalue=False - HelpText="Should food and drinks be included in the list of Junk items that get dropped when looting a body?" - actionText="Drop Food & Drinks" - enumText(0)="Don't Drop" - enumText(1)="Drop" - - refusedItems(0)=class'SoyFood' - refusedItems(1)=class'Candybar' - refusedItems(2)=class'Sodacan' - refusedItems(3)=class'Liquor40oz' - refusedItems(4)=class'LiquorBottle' - refusedItems(5)=class'WineBottle' -} diff --git a/GUI/DeusEx/Classes/MenuChoice_RefuseMelee.uc b/GUI/DeusEx/Classes/MenuChoice_RefuseMelee.uc deleted file mode 100644 index e9d3e75f3..000000000 --- a/GUI/DeusEx/Classes/MenuChoice_RefuseMelee.uc +++ /dev/null @@ -1,18 +0,0 @@ -class MenuChoice_RefuseMelee extends MenuChoice_ItemRefusal; -#compileif injections - -defaultproperties -{ - enabled=False - defaultvalue=False - HelpText="Should melee weapons be included in the list of Junk items that get dropped when looting a body?" - actionText="Drop Melee Weapons" - enumText(0)="Don't Drop" - enumText(1)="Drop" - - refusedItems(0)=class'WeaponCombatKnife' - refusedItems(1)=class'WeaponCrowbar' - refusedItems(2)=class'WeaponSword' - refusedItems(3)=class'WeaponNanoSword' - refusedItems(4)=class'WeaponBaton' -} diff --git a/GUI/DeusEx/Classes/MenuChoice_RefuseMisc.uc b/GUI/DeusEx/Classes/MenuChoice_RefuseMisc.uc deleted file mode 100644 index 56956f16f..000000000 --- a/GUI/DeusEx/Classes/MenuChoice_RefuseMisc.uc +++ /dev/null @@ -1,17 +0,0 @@ -class MenuChoice_RefuseMisc extends MenuChoice_ItemRefusal; -#compileif injections - -defaultproperties -{ - enabled=False - defaultvalue=False - HelpText="Should rebreathers, tech goggles, binoculars and flares be included in the list of Junk items that get dropped when looting a body?" - actionText="Drop Miscellaneous" - enumText(0)="Don't Drop" - enumText(1)="Drop" - - refusedItems(0)=class'Rebreather' - refusedItems(1)=class'TechGoggles' - refusedItems(2)=class'Binoculars' - refusedItems(3)=class'Flare' -} diff --git a/GUI/DeusEx/Classes/MenuChoice_RefuseUseless.uc b/GUI/DeusEx/Classes/MenuChoice_RefuseUseless.uc deleted file mode 100644 index cf4a93752..000000000 --- a/GUI/DeusEx/Classes/MenuChoice_RefuseUseless.uc +++ /dev/null @@ -1,15 +0,0 @@ -class MenuChoice_RefuseUseless extends MenuChoice_ItemRefusal; -#compileif injections - -defaultproperties -{ - enabled=True - defaultvalue=True - HelpText="Should cigarettes and zyme be included in the list of Junk items that get dropped when looting a body?" - actionText="Drop Cigarettes & Zyme" // text is too long without abreviating "and" - enumText(0)="Don't Drop" - enumText(1)="Drop" - - refusedItems(0)=class'Cigarettes' - refusedItems(1)=class'VialCrack' -} diff --git a/GUI/DeusEx/Classes/MenuChoice_ThrowMelee.uc b/GUI/DeusEx/Classes/MenuChoice_ThrowMelee.uc index 2586e2e1f..f4398040b 100644 --- a/GUI/DeusEx/Classes/MenuChoice_ThrowMelee.uc +++ b/GUI/DeusEx/Classes/MenuChoice_ThrowMelee.uc @@ -6,8 +6,8 @@ class MenuChoice_ThrowMelee extends DXRMenuUIChoiceBool; defaultproperties { - enabled=True - defaultvalue=True + enabled=False + defaultvalue=False HelpText="How to handle melee weapons when enemies die." actionText="Melee Weapons" enumText(0)="Don't Throw" diff --git a/GUI/DeusEx/Classes/MenuScreenRandoOptions.uc b/GUI/DeusEx/Classes/MenuScreenRandoOptions.uc index ef19ac1fb..10d5d1fa9 100644 --- a/GUI/DeusEx/Classes/MenuScreenRandoOptions.uc +++ b/GUI/DeusEx/Classes/MenuScreenRandoOptions.uc @@ -49,10 +49,11 @@ function CreateChoices() CreateChoice(class'MenuChoice_BarrelTextures'); CreateChoice(class'MenuChoice_DecoPickupBehaviour'); CreateChoice(class'MenuChoice_AutoLamps'); - CreateChoice(class'MenuChoice_RefuseUseless'); - CreateChoice(class'MenuChoice_RefuseFoodDrink'); - CreateChoice(class'MenuChoice_RefuseMelee'); - CreateChoice(class'MenuChoice_RefuseMisc'); + CreateChoice(class'MenuChoice_LootActionUseless'); + CreateChoice(class'MenuChoice_LootActionFoodSoda'); + CreateChoice(class'MenuChoice_LootActionAlcohol'); + CreateChoice(class'MenuChoice_LootActionMelee'); + CreateChoice(class'MenuChoice_LootActionMisc'); #endif CreateChoice(class'MenuChoice_PasswordAutofill'); diff --git a/GUI/DeusEx/Classes/MenuScreenRandoOptionsGameplay.uc b/GUI/DeusEx/Classes/MenuScreenRandoOptionsGameplay.uc index ef9bd85c7..d2c5be240 100644 --- a/GUI/DeusEx/Classes/MenuScreenRandoOptionsGameplay.uc +++ b/GUI/DeusEx/Classes/MenuScreenRandoOptionsGameplay.uc @@ -20,10 +20,11 @@ function CreateChoices() CreateChoice(class'MenuChoice_AutoLaser'); CreateChoice(class'MenuChoice_DecoPickupBehaviour'); CreateChoice(class'MenuChoice_AutoLamps'); - CreateChoice(class'MenuChoice_RefuseUseless'); - CreateChoice(class'MenuChoice_RefuseFoodDrink'); - CreateChoice(class'MenuChoice_RefuseMelee'); - CreateChoice(class'MenuChoice_RefuseMisc'); + CreateChoice(class'MenuChoice_LootActionUseless'); + CreateChoice(class'MenuChoice_LootActionFoodSoda'); + CreateChoice(class'MenuChoice_LootActionAlcohol'); + CreateChoice(class'MenuChoice_LootActionMelee'); + CreateChoice(class'MenuChoice_LootActionMisc'); #endif CreateChoice(class'MenuChoice_PasswordAutofill');