Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/v1.1.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
rlnt committed Apr 1, 2021
2 parents 8e273b2 + 8995dbf commit f2db414
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 44 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ The format is based on [Keep a Changelog][keep a changelog] and this project adh

## [Released]

## [1.1.0] - 2021-04-01

### Added
- checks to prevent setting overlevelled shields as DT shield
- checks to prevent favoriting or trashing the DT shield
- new rarity color on the item card of the DT shield
- several feedback sounds

### Changed
- improved console command execution


## [1.0.1] - 2021-03-27

### Added
Expand All @@ -35,5 +47,6 @@ The format is based on [Keep a Changelog][keep a changelog] and this project adh
<!-- Versions -->
[unreleased]: https://github.com/RLNT/bl2_deathtrapshield/compare/v1.0.0...HEAD
[released]: https://github.com/RLNT/bl2_deathtrapshield/releases
[1.1.0]: https://github.com/RLNT/bl2_deathtrapshield/compare/v1.0.1..v1.1.0
[1.0.1]: https://github.com/RLNT/bl2_deathtrapshield/compare/v1.0.0..v1.0.1
[1.0.0]: https://github.com/RLNT/bl2_deathtrapshield/releases/v1.0.0
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,21 @@
- this mod needs the [EridiumLib] in order to run
- since this is often not the case with SDK mods: yes, this has multiplayer support
- the default behaviour of the skill applies and the shield of Gaige will be shared when:
- you didn't unlock the skill sharing ability
- you don't set a Deathtrap shield
- the shield level is too high; you need to be able to equip it too
- you equip the Deathtrap shield to Gaige
- the Deathtrap shield will lose its status when:
- you set a new Deathtrap shield while already having one
- you equip the Deathtrap shield to Gaige
- you throw the Deathtrap shield on the ground
- you mark it as trash or favorite
- another character that is not a Mechromancer puts it in their inventory
- you can only set one Deathtrap shield at a time
- only Mechromancers can set Deathtrap shields and see the status
- you can't set shields as Deathtrap shield when:
- the level of the shield is too high (if you can't equip it yourself)
- you are not Mechromancer
- other useful information:
- this only works if you unlocked the `Sharing is Caring` skill
- you can only set one Deathtrap shield at a time
- you can't set a Deathtrap shield as trash or favorite (unset it first)
- the Deathtrap shield will have another color
- the hotkey to set the Deathtrap shield can be modified in the modded keybinds
- if you have a Deathtrap shield set, you won't be able to edit your save game in the SaveGame Editor unless you rejoin the game and remove the shield status, this can't be fixed

Expand Down
122 changes: 89 additions & 33 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unrealsdk
import webbrowser
from typing import Dict, List, Optional
from typing import Dict, List, Optional, Tuple

from Mods.ModMenu import (
EnabledSaveType,
Expand Down Expand Up @@ -46,7 +46,7 @@ class DeathtrapShield(SDKMod):
Name: str = "Deathtrap Shield"
Author: str = "Relentless"
Description: str = "Gives Deathtrap its own configurable shield from the inventory of Gaige."
Version: str = "1.0.1"
Version: str = "1.1.0"
_EridiumVersion: str = "0.4.1"

SupportedGames: Game = Game.BL2
Expand All @@ -61,6 +61,9 @@ class DeathtrapShield(SDKMod):
# endregion Mod Info

_BlockFunStats: bool = False
_BlockTitle: bool = False
_RarityColorTuple: Tuple[int, int, int, int] = (166, 40, 255, 255)
_RarityColorHex: str = "#FF28A6"

# region Mod Setup
def __init__(self) -> None:
Expand Down Expand Up @@ -154,6 +157,37 @@ def _resetAllShields(self, shield: unrealsdk.UObject, playerPawn: unrealsdk.UObj

# endregion Helper Functions

# region Console Commands
@Hook("Engine.GameInfo.PreCommitMapChange")
def _showStatusMenu(
self, caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct
) -> bool:
"""
Handles executing Console Commands since there is a string bug which
messes with some stuff we want to do here.
https://github.com/bl-sdk/PythonSDK/issues/28
We use PrecommitMapChange as it's only fired once for each character
when filtering the parameters correctly.
"""

# make sure this is only executed once when joining the game
if params.PreviousMapName != "Loader":
return True

# edit the skill description of the shield sharing ability
_skillDescription: List[str] = [
"Gives [skill]Deathtrap[-skill] a copy of a configurable",
"[skill]shield[-skill] from your inventory.",
]
caller.ConsoleCommand(
"set SkillDefinition'GD_Tulip_Mechromancer_Skills.BestFriendsForever."
"SharingIsCaring' SkillDescription " + " ".join(_skillDescription)
)

return True

# endregion Console Commands

# region Item Handling
@Hook("WillowGame.DeathtrapActionSkill.TryToShareShields")
def _tryToShareShields(
Expand Down Expand Up @@ -223,6 +257,27 @@ def _tryToShareShields(
# don't call the original function since we handled everything ourselves
return False

@Hook("WillowGame.InventoryListPanelGFxObject.extOnTrashFavChanged")
def _extOnTrashFavChanged(
self, caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct
) -> bool:
"""
Prevents setting the DT shield as trash or favorite.
"""
item: unrealsdk.UObject = caller.GetSelectedThing()
oldMark: int = item.GetMark()

if item is None:
return True

if self._isValidShield(item) is True and oldMark == 3:
item.SetMark(3)
caller.OwningMovie.PlayUISound("ResultFailure")
caller.OwningMovie.RefreshInventoryScreen(True)
return False

return True

# endregion Item Handling

# region Hotkey Handling
Expand Down Expand Up @@ -270,13 +325,20 @@ def _normalInputKey(
if self._isValidShield(item) is False:
return True

# make sure the shield isn't overlevelled
if item.CanBeUsedBy(playerController.Pawn) is False:
caller.ParentMovie.PlayUISound("ResultFailure")
return True

# save the state so it doesn't switch to the first item again
caller.BackpackPanel.SaveState()

if item.GetMark() == 3:
item.SetMark(1)
caller.ParentMovie.PlayUISound("UnEquip")
else:
item.SetMark(3)
caller.ParentMovie.PlayUISound("FinishEquip")
self._resetAllShields(item, playerController.MyWillowPawn)

# refresh the inventory screen
Expand Down Expand Up @@ -323,6 +385,10 @@ def _setTooltipText(
if self._isValidShield(item) is False:
return True

# make sure the shield isn't overlevelled
if item.CanBeUsedBy(playerController.Pawn) is False:
return True

"""
Get the original hotkey text and append our hotkey.
The hotkey text changes depending if it's already set as DT shield.
Expand All @@ -341,36 +407,6 @@ def _setTooltipText(
caller.SetTooltipText(result)
return False

@Hook("WillowGame.WillowPlayerController.ShowStatusMenu")
def _showStatusMenu(
self, caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct
) -> bool:
"""
Handles executing Console Commands since there is a string bug.
https://github.com/bl-sdk/PythonSDK/issues/28
"""

# edit the skill description of the shield sharing ability
_skillDescription: List[str] = [
"Gives [skill]Deathtrap[-skill] a copy of a configurable",
"[skill]shield[-skill] from your inventory.",
]

currentDescriptionObj = unrealsdk.FindObject(
"SkillDefinition", "GD_Tulip_Mechromancer_Skills.BestFriendsForever.SharingIsCaring"
)
if currentDescriptionObj is None:
return True
currentDescription: str = currentDescriptionObj.SkillDescription

if currentDescription != " ".join(_skillDescription):
caller.ConsoleCommand(
"set SkillDefinition'GD_Tulip_Mechromancer_Skills.BestFriendsForever."
"SharingIsCaring' SkillDescription " + " ".join(_skillDescription)
)

return True

@Hook("WillowGame.ItemCardGFxObject.SetItemCardEx")
def _setItemCardEx(
self, caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct
Expand Down Expand Up @@ -408,16 +444,36 @@ def _setItemCardEx(
if text is None:
text = ""

text += '<font color="#00FF9C">'
text += f'<font color="{self._RarityColorHex}">'
text += "• Current Deathtrap Shield"
text += "</font>"

"""
The hooked function is pretty complex so before replicating its logic,
we pass our modified text to it but block it from overwriting.
We also overwrite the rarity color here and also block the overwrite.
Color format is BGRA in a tuple.
"""
caller.SetFunStats(text)
self._BlockFunStats = True
caller.SetTitle(
item.GetManufacturer().FlashLabelName,
item.GetShortHumanReadableName(),
self._RarityColorTuple,
item.GetZippyFrame(),
item.GetElementalFrame(),
item.IsReadied(),
)
self._BlockTitle = True
return True

@Hook("WillowGame.ItemCardGFxObject.SetTitle")
def _setTitle(
self, caller: unrealsdk.UObject, function: unrealsdk.UFunction, params: unrealsdk.FStruct
) -> bool:
if self._BlockTitle:
self._BlockTitle = False
return False
return True

@Hook("WillowGame.ItemCardGFxObject.SetFunStats")
Expand Down
13 changes: 7 additions & 6 deletions modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
"Notes:\n",
"- since this is often not the case with SDK mods: yes, this has multiplayer support\n",
"- the default behaviour of the skill applies and the shield of Gaige will be shared when:\n",
" - you didn't unlock the skill sharing ability\n",
" - you don't set a Deathtrap shield\n",
" - the shield level is too high; you need to be able to equip it too\n",
" - you equip the Deathtrap shield to Gaige\n",
"- the Deathtrap shield will lose its status when:\n",
" - you set a new Deathtrap shield while already having one\n",
" - you equip the Deathtrap shield to Gaige\n",
" - you throw the Deathtrap shield on the ground\n",
" - you mark it as trash or favorite\n",
" - another character that is not a Mechromancer puts it in their inventory\n",
"- you can only set one Deathtrap shield at a time\n",
"- only Mechromancers can set Deathtrap shields and see the status\n",
"- other useful information:\n",
" - this only works if you unlocked the `Sharing is Caring` skill\n",
" - you can only set one Deathtrap shield at a time\n",
" - you can't set a Deathtrap shield as trash or favorite (unset it first)\n",
" - the Deathtrap shield will have another color\n",
"- the hotkey to set the Deathtrap shield can be modified in the modded keybinds\n",
"- if you have a Deathtrap shield set, you won't be able to edit your save game in the SaveGame Editor unless you rejoin the game and remove the shield status, this can't be fixed\n",
"\n",
Expand All @@ -38,8 +38,9 @@
"supports": ["BL2"],
"issues": "https://github.com/RLNT/bl2_deathtrapshield/issues",
"source": "https://github.com/RLNT/bl2_deathtrapshield",
"latest": "1.0.1",
"latest": "1.1.0",
"versions": {
"1.1.0": "https://github.com/RLNT/bl2_deathtrapshield/releases/tag/v1.1.0",
"1.0.1": "https://github.com/RLNT/bl2_deathtrapshield/releases/tag/v1.0.1",
"1.0.0": "https://github.com/RLNT/bl2_deathtrapshield/releases/tag/v1.0.0"
},
Expand Down

0 comments on commit f2db414

Please sign in to comment.