development
parent
b3058adf18
commit
315b7910eb
5 changed files with 32 additions and 85 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,98 +1,41 @@ |
|||||||
Scriptname _00E_FS_Dismantle_Workbench extends ObjectReference |
Scriptname _00E_FS_Dismantle_Workbench extends ObjectReference |
||||||
{lets the player melt down items to one of its base components, extends the crafting classes} |
{lets the player melt down items to one of its base components, extends the crafting classes} |
||||||
|
|
||||||
; properties |
|
||||||
Actor Property PlayerREF Auto |
Actor Property PlayerREF Auto |
||||||
FormList Property _00E_DismantleList Auto |
ObjectReference Property _00E_RemoveAllItems_TrashContainer Auto |
||||||
FormList Property _00E_DismantleItemList Auto |
|
||||||
FormList Property _00E_DismantleResetList Auto |
|
||||||
Message Property _00E_CheckForDismantlingMSG Auto |
|
||||||
Keyword Property CraftingSmelterDismantling Auto |
|
||||||
Keyword Property InvisibleDismantling Auto |
|
||||||
Perk Property _00E_Class_Phasmalist_P04_A_ArcaneBreakdown Auto |
|
||||||
|
|
||||||
; events |
|
||||||
Event OnInit() |
Event OnInit() |
||||||
BlockActivation() |
BlockActivation() |
||||||
EndEvent |
EndEvent |
||||||
|
|
||||||
Event OnActivate(ObjectReference akActionRef) |
Event OnActivate(ObjectReference akActionRef) |
||||||
|
|
||||||
If Self.IsActivationBlocked() |
Weapon rightHand = PlayerREF.GetEquippedWeapon(false) |
||||||
RegisterForMenu("Crafting Menu") |
Weapon leftHand = PlayerREF.GetEquippedWeapon(true) |
||||||
; GenerateMeltDownList() is relatively slow due to using formlists hence we notify the player that something is calculated in the background |
|
||||||
_00E_CheckForDismantlingMSG.Show() |
|
||||||
GenerateMeltDownList() |
|
||||||
Self.Activate(PlayerREF, true) |
|
||||||
EndIf |
|
||||||
|
|
||||||
Endevent |
if rightHand || leftHand |
||||||
|
_00E_RemoveAllItems_TrashContainer.RemoveAllItems() |
||||||
Event OnMenuClose(String MenuName) |
|
||||||
|
|
||||||
If menuName == ("Crafting Menu") |
|
||||||
UnregisterForMenu("Crafting Menu") |
|
||||||
ResetMeltDownList() |
|
||||||
; only enable the player controls after everything is reset properly |
|
||||||
Game.EnablePlayerControls() |
|
||||||
EndIf |
|
||||||
|
|
||||||
EndEvent |
|
||||||
|
|
||||||
; functions |
|
||||||
Function GenerateMeltDownList() |
|
||||||
; this function is responsible for filling a list based on the items in the players inventory which can be melted down to crafting material |
|
||||||
|
|
||||||
Int iTotalItemCount = PlayerREF.GetNumItems() |
|
||||||
Int iItemCount = 0 |
|
||||||
Form ItemToCheck |
|
||||||
Bool bPlayerHasArcaneBreakdown = PlayerREF.HasPerk(_00E_Class_Phasmalist_P04_A_ArcaneBreakdown) |
|
||||||
Form equippedItemLeft = PlayerRef.GetEquippedObject(0) |
|
||||||
Form equippedItemRight = PlayerRef.GetEquippedObject(1) |
|
||||||
|
|
||||||
While iItemCount < iTotalItemCount |
|
||||||
ItemToCheck = PlayerREF.GetNthForm(iItemCount) |
|
||||||
|
|
||||||
If (ItemToCheck as Armor) != None ; armor |
|
||||||
;checks the item if it's equipped and if it's either enchanted or if the player has the perk to dismantle enchantmented items |
|
||||||
If ItemToCheck != equippedItemRight && ItemToCheck != equippedItemLeft && PlayerREF.IsEquipped(ItemToCheck) == False |
|
||||||
If bPlayerHasArcaneBreakdown || (ItemToCheck as Armor).GetEnchantment() == None |
|
||||||
AddItemToDismantleList(ItemToCheck) |
|
||||||
EndIf |
|
||||||
EndIf |
|
||||||
ElseIf (ItemToCheck as Weapon) != None ; weapon |
|
||||||
;checks the item if it's equipped and if it's either enchanted or if the player has the perk to dismantle enchantmented items |
|
||||||
; Note: IsEquipped does not work for any stuff in the left hand when dual wielding |
|
||||||
If ItemToCheck != equippedItemRight && ItemToCheck != equippedItemLeft |
|
||||||
If bPlayerHasArcaneBreakdown || (ItemToCheck as Weapon).GetEnchantment() == None |
|
||||||
AddItemToDismantleList(ItemToCheck) |
|
||||||
EndIf |
|
||||||
EndIf |
|
||||||
EndIf |
|
||||||
|
|
||||||
iItemCount += 1 |
if rightHand == leftHand |
||||||
EndWhile |
_00E_RemoveAllItems_TrashContainer.AddItem(rightHand, 2, true) |
||||||
EndFunction |
else |
||||||
|
if rightHand |
||||||
Function AddItemToDismantleList(Form itemToAdd) |
_00E_RemoveAllItems_TrashContainer.AddItem(rightHand, 1, true) |
||||||
; if the item passes the checks, we need to set the workbenchkeyword of the respective constructible object so it gets displayed properly in the menu |
endif |
||||||
; it also adds it to the reset list so the keyword gets set back to the default one after exiting the menu |
if leftHand |
||||||
Int iFoundAtIndex = _00E_DismantleItemList.Find(itemToAdd) |
_00E_RemoveAllItems_TrashContainer.AddItem(leftHand, 1, true) |
||||||
If iFoundAtIndex >= 0 |
endif |
||||||
ConstructibleObject recipe = _00E_DismantleList.GetAt(iFoundAtIndex) as ConstructibleObject |
endif |
||||||
recipe.SetWorkBenchKeyword(CraftingSmelterDismantling) |
endif |
||||||
_00E_DismantleResetList.AddForm(recipe) |
|
||||||
EndIf |
Game.EnablePlayerControls() |
||||||
EndFunction |
Activate(PlayerREF, true) |
||||||
|
|
||||||
Function ResetMeltDownList() |
if rightHand || leftHand |
||||||
; this function resets the workbenchkeyword back to default |
while ! Game.IsLookingControlsEnabled() |
||||||
Int iTotalRecipesToReset = _00E_DismantleResetList.GetSize() |
Utility.Wait(0.5) |
||||||
Int iRecipesToReset = iTotalRecipesToReset |
endwhile |
||||||
|
_00E_RemoveAllItems_TrashContainer.RemoveAllItems() |
||||||
|
endif |
||||||
|
|
||||||
While iRecipesToReset > 0 |
Endevent |
||||||
iRecipesToReset -= 1 |
|
||||||
(_00E_DismantleResetList.GetAt(iRecipesToReset) as ConstructibleObject).SetWorkBenchKeyword(InvisibleDismantling) |
|
||||||
EndWhile |
|
||||||
_00E_DismantleResetList.Revert() |
|
||||||
EndFunction |
|
||||||
|
Loading…
Reference in new issue