Skip to content

Commit

Permalink
support for URI variations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Scrivener07 committed Jul 16, 2018
1 parent b93887a commit 60b4ae4
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Event OnQuestInit()
Try(Fallout4, Armor_Gasmask)
Try(Fallout4, ClothesBlackRimGlasses)
Try(Fallout4, Armor_BoS_Science_Scribe_Helmet)

Try(ODST, Armor_H3_ODST_Helmet)
Try(ODST, Armor_H3_ODST_HelmetHaunted)
Try(ODST, Armor_ODST_Helmet)
Try(ODST, Armor_ODST_Recon_Helmet)

Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_TechSuit)
Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_Halo5_MarkIV_Left_Arm)
Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_Halo5_MarkIV_Legs)
Expand Down Expand Up @@ -69,6 +75,7 @@ Event OnQuestInit()
Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_Halo5_MarkIV_Helmet)
Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_Halo5_Argus_Helmet)
Try(CommonwealthSpartanRedux, Armor_CommonwealthSpartan_Halo5_MarkVI_Helmet)

WriteLine(self, "Added items for debug testing.")
EndEvent

Expand Down Expand Up @@ -98,6 +105,14 @@ Group Vanilla
int Property Armor_BoS_Science_Scribe_Helmet = 0x000E4501 AutoReadOnly ;/ No Biped Eye Slot /;
EndGroup

Group ODST
string Property ODST = "ProjectHelljumper.esp" AutoReadOnly
int Property Armor_H3_ODST_Helmet = 0x00006ADB AutoReadOnly
int Property Armor_H3_ODST_HelmetHaunted = 0x00006AFF AutoReadOnly
int Property Armor_ODST_Helmet = 0x00001735 AutoReadOnly
int Property Armor_ODST_Recon_Helmet = 0x0001729C AutoReadOnly
EndGroup

Group BrandonPotter
string Property CommonwealthSpartanRedux = "Commonwealth_Spartan_Redux.esp" AutoReadOnly
int Property Armor_CommonwealthSpartan_TechSuit = 0x0003BC8D AutoReadOnly
Expand Down
4 changes: 2 additions & 2 deletions Data/Overlays.esp
Git LFS file not shown
14 changes: 12 additions & 2 deletions Data/Scripts/Source/FO4_Overlays/Build.ppj
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<?xml version="1.0"?>
<PapyrusProject xmlns="PapyrusProject.xsd" Output="..\..\" Flags="Institute_Papyrus_Flags.flg" Asm="Discard" Optimize="false" Release="false" Final="false">
<?xml version='1.0'?>
<!-- Overlays -->
<!-- http://www.creationkit.com/fallout4/index.php?title=Papyrus_Projects -->
<PapyrusProject
xmlns="PapyrusProject.xsd"
Flags="Institute_Papyrus_Flags.flg"
Output="..\..\"
Asm="Discard"
Optimize="false"
Release="false"
Final="false"
>
<Imports>
<Import>.</Import>
<Import>..\F4SE</Import>
Expand Down
177 changes: 134 additions & 43 deletions Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Framework.psc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ import Fallout
import Fallout:Overlays
import Fallout:Overlays:Papyrus

;| Slot | Hexadecimal | Decimal |
;|------------------------------|
;| 30 | 0x00000001 | 1 |
;| 47 | 0x00020000 | 131072 |

Actor Player
;---------------------------------------------
string URI

string EquippedState = "Equipped" const
;---------------------------------------------
int Invalid = -1 const
int BipedEyes = 17 const
bool ThirdPerson = false const

string EquippedState = "Equipped" const


; Events
;---------------------------------------------
Expand All @@ -32,24 +38,130 @@ Event OnQuestShutdown()
EndEvent


; Events
Event Actor.OnItemEquipped(Actor sender, Form akBaseObject, ObjectReference akReference)
Equipment()
EndEvent


Event Actor.OnItemUnequipped(Actor akSender, Form akBaseObject, ObjectReference akReference)
{EMPTY}
EndEvent


; Functions
;---------------------------------------------

Event Actor.OnItemEquipped(Actor sender, Form akBaseObject, ObjectReference akReference)
Function Equipment()
string value = GetURI()
If (StringIsNoneOrEmpty(value) != true) ; do not allow a change to none/empty
If (TryChange(value))
ChangeState(self, EquippedState)
EndIf
EndIf
EndFunction

string Function GetURI()
int slot = GetSlot()
If (slot > Invalid)
string value
ObjectMod[] mods = Player.GetWornItemMods(slot)
If (mods)
int index = 0
While (index < mods.Length)
value = GetLooseMod(mods[index])
If (!StringIsNoneOrEmpty(value))
WriteLine(self, "GetURI", "LooseMod:'"+value+"'")
return value
EndIf

; value = GetObjectMod(mods[index])
; If (!StringIsNoneOrEmpty(value))
; WriteLine(self, "GetURI", "ObjectMod:'"+value+"'")
; return value
; EndIf

index += 1
EndWhile
EndIf
;---------------------------------------------
value = GetDefault(slot)
WriteLine(self, "GetURI", "Default:'"+value+"'")
return value
Else
WriteUnexpectedValue(self, "Actor.OnItemEquipped", "value", "The value cannot be none or empty.")
return ""
EndIf
EndEvent
EndFunction


Event Actor.OnItemUnequipped(Actor akSender, Form akBaseObject, ObjectReference akReference)
{EMPTY}
EndEvent
int Function GetSlot()
int slot = 0
While (slot <= BipedEyes)
Armor armo = Player.GetWornItem(slot, ThirdPerson).Item as Armor
If (armo && HasSlotMask(armo, kSlotMask47))
return slot
EndIf
slot += 1
EndWhile
return Invalid
EndFunction


bool Function HasSlotMask(Armor armo, int value)
return Math.LogicalAnd(armo.GetSlotMask(), value) == value
EndFunction



string Function GetLooseMod(ObjectMod omod)
{Defined by the loose mod icon path.}
MiscObject misc = omod.GetLooseMod()
If (misc && misc.HasKeyword(ArmorBodyPartEyes))
return misc.GetIconPath()
Else
return ""
EndIf
EndFunction


; string Function GetObjectMod(ObjectMod omod)
; {Derived from the object mod model path.}
; ObjectMod:PropertyModifier[] properties = omod.GetPropertyModifiers()
; If (properties)
; int index = properties.FindStruct("object", ArmorBodyPartEyes)
; If (index > Invalid)
; ObjectMod:PropertyModifier modifier = properties[index]
; bool bTarget = (modifier.Target == omod.Armor_Target_pkKeywords)
; bool bOperator = (modifier.Operator == omod.Modifier_Operator_Add)
; If (bTarget && bOperator)
; return omod.GetWorldModelPath()
; Else
; return ""
; EndIf
; Else
; return ""
; EndIf
; Else
; return ""
; EndIf
; EndFunction


string Function GetDefault(int slot)
{Derived from the armor model name.}
return Player.GetWornItem(slot, ThirdPerson).ModelName
EndFunction


bool Function TryChange(string value)
If (value != URI)
WriteChangedValue(self, "URI", URI, value)
URI = value
return true
Else
WriteUnexpectedValue(self, "TryChange", "value", "The URI already equals '"+value+"'")
return false
EndIf
EndFunction


; States
Expand All @@ -67,6 +179,7 @@ State Equipped
;---------------------------------------------

Event OnGameReload()
WriteLine(self, "Equipped.OnGameReload")
OverlayMenu.Open()
EndEvent

Expand Down Expand Up @@ -122,35 +235,13 @@ State Equipped
EndState


Function Equipment()
{EMPTY}
WriteNotImplemented(self, "Equipment", "This should only be called in the "+EquippedState+" state.")
EndFunction


; Methods
;---------------------------------------------

bool Function TryChange(string value)
If (value != URI)
WriteChangedValue(self, "URI", URI, value)
URI = value
return true
Else
WriteUnexpectedValue(self, "TryChange", "value", "The URI already equals '"+value+"'")
return false
EndIf
EndFunction


string Function GetURI()
return Player.GetWornItem(BipedEyes, ThirdPerson).ModelName
EndFunction


; Properties
;---------------------------------------------

Group Properties
Keyword Property ArmorBodyPartEyes Auto Const Mandatory
EndGroup

Group Overlay
Overlays:Menu Property OverlayMenu Auto Const Mandatory
EndGroup
Expand All @@ -163,10 +254,10 @@ Group Camera
EndProperty
EndGroup

Group Equipped
bool Property HasEquipped Hidden
bool Function Get()
return StringIsNoneOrEmpty(URI) != true
EndFunction
EndProperty
EndGroup
; Group Equipped
; bool Property HasEquipped Hidden
; bool Function Get()
; return StringIsNoneOrEmpty(URI) != true
; EndFunction
; EndProperty
; EndGroup
24 changes: 17 additions & 7 deletions Data/Scripts/Source/FO4_Overlays/Fallout/Overlays/Papyrus.psc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ScriptName Fallout:Overlays:Papyrus Const Native Hidden
;---------------------------------------------
; Writes messages as lines in a log file.

bool Function WriteLine(string prefix, string text) Global DebugOnly
bool Function Write(string prefix, string text) Global DebugOnly
string filename = "Overlays" const
text = prefix + " " + text
If(Debug.TraceUser(filename, text))
Expand All @@ -19,7 +19,7 @@ EndFunction

bool Function WriteNotification(string prefix, string text) Global DebugOnly
Debug.Notification(text)
return WriteLine(prefix, text)
return Write(prefix, text)
EndFunction


Expand All @@ -29,27 +29,37 @@ bool Function WriteMessage(string prefix, string title, string text = "") Global
value = title+"\n"+text
EndIf
Debug.MessageBox(value)
return WriteLine(prefix, title+" "+text)
return Write(prefix, title+" "+text)
EndFunction


; Formated Messages
; Debug
;---------------------------------------------
; Writes script messages as lines in a log file.

bool Function WriteLine(var script, string member, string text = "") Global DebugOnly
If (StringIsNoneOrEmpty(text))
return Write(script, member)
Else
return Write(script+"["+member+"]", text)
EndIf
EndFunction


bool Function WriteUnexpected(var script, string member, string text = "") Global DebugOnly
return WriteLine(script+"["+member+"]", "The member '"+member+"' had an unexpected operation. "+text)
return Write(script+"["+member+"]", "The member '"+member+"' had an unexpected operation. "+text)
EndFunction


bool Function WriteUnexpectedValue(var script, string member, string variable, string text = "") Global DebugOnly
return WriteLine(script+"["+member+"."+variable+"]", "The member '"+member+"' with variable '"+variable+"' had an unexpected operation. "+text)
return Write(script+"["+member+"."+variable+"]", "The member '"+member+"' with variable '"+variable+"' had an unexpected operation. "+text)
EndFunction


bool Function WriteNotImplemented(var script, string member, string text = "") Global DebugOnly
{The exception that is thrown when a requested method or operation is not implemented.}
; The exception is thrown when a particular method, get accessors, or set accessors is present as a member of a type but is not implemented.
return WriteLine(script, member+": The member '"+member+"' was not implemented. "+text)
return Write(script, member+": The member '"+member+"' was not implemented. "+text)
EndFunction


Expand Down

0 comments on commit 60b4ae4

Please sign in to comment.