EyeDeck
Active Member
- Messages
- 123
After getting a bunch of requests for this, I finally looked into it today. I've written a feature so that level 2+ Logistics Stations (the level at which the plot gets the ham radio and radio tower) will register themselves as "virtual" Communications Desks.
This was one of those rare cases where the code I wrote compiled and worked as expected the first time, despite being a heavily reverse-engineered hack.
Anyway, since this functionally eliminates the need to build any of Salvage Beacons' native communications desks at all provided you're using my mod, @kinggath, is it okay if I release this? I intend for this feature to be disabled by default, even if Salvage Beacons is detected, so the user will have to knowingly go into the settings and flip the switch to turn it on.
Code:
; --------------- Salvage Beacons Compat ---------------
; Plugin = SalvageBeacons.esp
; SB_CommunicationsDesk 0x3D5F
; SB_SalvageBeaconsQuest = 0x80F9
; ActiveCommStations = alias index 81
; PlayerHasWorkedCommStation = 0x2673
; DLCFarHarborHasWorkedCommStation = 0x268D
; DLC03FarHarbor "The Island" = 0xB0F in DLCCoast.esm
; SB_HasActiveCommStation 0x2675
string SBstr = "SalvageBeacons.esp" const
Function AddVirtualCommDesk(WorkshopScript thisWorkshop)
lsTrace("SB Compat: Registering virtual Comm Desk to " + thisWorkshop + "...")
Keyword SB_HasActiveCommStation = Game.GetFormFromFile(0x2675, SBstr) as Keyword
GlobalVariable PlayerHasWorkedCommStation = Game.GetFormFromFile(0x2673, SBstr) as GlobalVariable
GlobalVariable DLCFarHarborHasWorkedCommStation = Game.GetFormFromFile(0x268D, SBstr) as GlobalVariable
Quest SB_SalvageBeaconsQuest = Game.GetFormFromFile(0x80F9, SBstr) as Quest
RefCollectionAlias ActiveCommStations = SB_SalvageBeaconsQuest.GetAlias(81) as RefCollectionAlias
Worldspace DLC03FarHarbor = Game.GetFormFromFile(0xB0F, "DLCCoast.esm") as Worldspace
ActiveCommStations.AddRef(thisWorkshop)
thisWorkshop.AddKeyword(SB_HasActiveCommStation)
if (thisWorkshop.GetWorldspace() != DLC03FarHarbor)
PlayerHasWorkedCommStation.SetValue(1)
else
DLCFarHarborHasWorkedCommStation.SetValue(1)
endif
lsTrace("...finished registering virtual comm desk.")
EndFunction
Function RemoveVirtualCommDesk(WorkshopScript thisWorkshop)
lsTrace("SB Compat: Removing virtual Comm Desk from " + thisWorkshop + "...")
; first check if any actual comm desks are here - if so just let them handle this and bail out
ObjectReference[] thisSettlementCommStations = thisWorkshop.FindAllReferencesOfType(Game.GetFormFromFile(0x3D5F, SBstr), 10000)
if (thisSettlementCommStations.length)
ScriptObject commStation = thisSettlementCommStations[0].CastAs("SB_commdesk")
Var[] args = new var[1]
args[0] = thisWorkshop
commStation.CallFunctionNoWait("FindActiveCommStation", args)
lsTrace("...Responsibility passed onto " + commStation + ".")
return
endif
; it's in SB_commdesk.FindActiveStation(), so it seems appropriate here
Utility.Wait(5)
Keyword SB_HasActiveCommStation = Game.GetFormFromFile(0x2675, SBstr) as Keyword
GlobalVariable PlayerHasWorkedCommStation = Game.GetFormFromFile(0x2673, SBstr) as GlobalVariable
GlobalVariable DLCFarHarborHasWorkedCommStation = Game.GetFormFromFile(0x268D, SBstr) as GlobalVariable
Quest SB_SalvageBeaconsQuest = Game.GetFormFromFile(0x80F9, SBstr) as Quest
RefCollectionAlias ActiveCommStations = SB_SalvageBeaconsQuest.GetAlias(81) as RefCollectionAlias
Worldspace DLC03FarHarbor = Game.GetFormFromFile(0xB0F, "DLCCoast.esm") as Worldspace
ActiveCommStations.RemoveRef(thisWorkshop)
thisWorkshop.RemoveKeyword(SB_HasActiveCommStation)
bool isFarHarbor = (thisWorkshop.GetWorldspace() == DLC03FarHarbor)
bool otherActiveCommStation = false
bool otherActiveFarHarborCommStation = false
if (!isFarHarbor)
for int i = 0 to ActiveCommStations.GetCount() - 1
if (ActiveCommStations.GetAt(i).GetWorldspace() != DLC03FarHarbor)
otherActiveCommStation = true
break
endif
endfor
else
for int i = 0 to ActiveCommStations.GetCount() - 1
if (ActiveCommStations.GetAt(i).GetWorldspace() == DLC03FarHarbor)
otherActiveFarHarborCommStation = true
break
endif
endfor
endif
if (!isFarHarbor && !otherActiveCommStation)
lsTrace("\tCould not find another comm station - setting PlayerHasWorkedCommStation to 0.")
PlayerHasWorkedCommStation.SetValue(0)
endif
if (isFarHarbor && !otherActiveFarHarborCommStation)
lsTrace("\tCould not find another comm station in Far Harbor - setting DLCFarHarborHasWorkedCommStation to 0.")
DLCFarHarborHasWorkedCommStation.SetValue(0)
endif
lsTrace("...finished unregistering virtual comm desk.")
EndFunction
; --------------- End Salvage Beacons Compat ---------------
Anyway, since this functionally eliminates the need to build any of Salvage Beacons' native communications desks at all provided you're using my mod, @kinggath, is it okay if I release this? I intend for this feature to be disabled by default, even if Salvage Beacons is detected, so the user will have to knowingly go into the settings and flip the switch to turn it on.