Skip to content

Commit

Permalink
added interface for ddi.
Browse files Browse the repository at this point in the history
  • Loading branch information
mort65 committed Jul 9, 2024
1 parent bcacf6f commit 7342bbb
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 69 deletions.
83 changes: 83 additions & 0 deletions Simple Prostitution/Scripts/Source/zzzmrt_sp_ddi_interface.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Scriptname zzzmrt_sp_ddi_interface extends Quest

Form[] ddkeys
Bool property bChecked = False Auto Hidden

event OnEndState()
Utility.Wait(5.0) ; Wait before entering active state to help avoid making function calls to scripts that may not have initialized yet.
setVars()
endevent

Function setVars()
int iIndex = 0
form restraintsKey = Game.GetFormFromFile(0x01775f, "Devious Devices - Integration.esm")
if restraintsKey && restraintsKey.getType() == 45
iIndex += 1
else
restraintsKey = None
Debug.Trace("Simple Prostitution: [DD] Restraint key not found.")
endif
form chastityKey = Game.GetFormFromFile(0x008a4f, "Devious Devices - Integration.esm")
if chastityKey && chastityKey.getType() == 45
iIndex += 1
else
chastityKey = None
Debug.Trace("Simple Prostitution: [DD] Chastity key not found.")
endif
form piercingKey = Game.GetFormFromFile(0x0409a4, "Devious Devices - Integration.esm")
if piercingKey && piercingKey.getType() == 45
iIndex += 1
else
piercingKey = None
Debug.Trace("Simple Prostitution: [DD] Piercing key not found.")
endif
if iIndex > 0
ddkeys = utility.createFormArray(iIndex)
While iIndex > 0
iIndex -= 1
if piercingKey && (ddkeys.find(piercingKey) < 0)
ddkeys[iIndex] = piercingKey
elseif chastityKey && (ddkeys.find(chastityKey) < 0)
ddkeys[iIndex] = chastityKey
elseif restraintsKey && (ddkeys.find(restraintsKey) < 0)
ddkeys[iIndex] = restraintsKey
endif
endWhile
Debug.Notification("Simple Prostitution: Devious Devices Integration detected.")
endif
endfunction

Bool function GetIsInterfaceActive()
if GetState() == "Installed"
return true
endif
return false
endfunction

function PlayerLoadsGame(Bool bForce = False)
Debug.trace("Simple Prostitution: PlayerLoadsGame() triggered for " + self)

; Is the soft dependency installed and is our script in the right state? If not change state.
if Game.IsPluginInstalled("Devious Devices - Integration.esm")
if GetState() != "Installed"
GoToState("Installed")
elseif bForce
setVars()
endif
else
if GetState() != ""
GoToState("")
endif
endif
bChecked = True
endfunction

Int Function iAddRandomKeyToActor(ObjectReference akRef, Int aiNum = 1)
return 0
endfunction

state Installed
Int Function iAddRandomKeyToActor(ObjectReference akRef, Int aiNum = 1)
return zzzmrt_sp_int_ddi._iAddRandomKeyToActor(akRef, ddkeys, aiNum)
endfunction
endState
28 changes: 28 additions & 0 deletions Simple Prostitution/Scripts/Source/zzzmrt_sp_int_ddi.psc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Scriptname zzzmrt_sp_int_ddi Hidden


Int function _iAddRandomKeyToActor(ObjectReference akRef, Form[] akeyArr, Int aiNum = 1) Global
if (aiNum < 1) || (akeyArr.Length < 1)
return 0
endif
Int iResult = 0
Int iTotalKeys = akeyArr.Length
Int[] KeyNum = utility.createIntArray(iTotalKeys, 0)
Int jIndex
Int iIndex = 0
while iIndex < aiNum
jIndex = Utility.RandomInt(0, iTotalKeys - 1)
KeyNum[jIndex] = KeyNum[jIndex] + 1
iIndex += 1
endWhile
iIndex = iTotalKeys
While iIndex > 0
iIndex -= 1
jIndex = KeyNum[iIndex]
if akeyArr[iIndex] && jIndex > 0
akRef.Additem(akeyArr[iIndex], jIndex)
iResult += jIndex
endif
EndWhile
return iResult
EndFunction
72 changes: 3 additions & 69 deletions Simple Prostitution/Scripts/Source/zzzmrt_sp_main_qst_script.psc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ zzzmrt_sp_flowergirls_interface property FlowerGirlsInterface auto
zzzmrt_sp_sexlab_interface property SexLabInterface auto
zzzmrt_sp_ostim_interface property OStimInterface auto
zzzmrt_sp_licenses_interface property LicensesInterface auto
zzzmrt_sp_ddi_interface property DDI_Interface auto
Quest Property OStimInterfaceQst Auto
Quest Property FlowerGirlsInterfaceQst Auto
Quest Property SexLabInterfaceQst Auto
Expand Down Expand Up @@ -1011,10 +1012,6 @@ Bool Function bCheckPO3Extender()
return false
EndFunction

Bool Function bCheckDDIntegeration()
return Game.IsPluginInstalled("Devious Devices - Integration.esm")
EndFunction

Bool Function bAllPosAllowed(Float fVagChance, Float fAnalChance, Float fOralChance)
return ((fVagChance > 0.0) && (fAnalChance > 0.0) && (fOralChance > 0.0))
EndFunction
Expand Down Expand Up @@ -1493,68 +1490,6 @@ function addDibelMarkToPlayer(float fChance, int iNumPartners = 1)
endif
endFunction

Int function iAddDeviousKeyToPlayer(int iNum = 1)
if iNum < 1
return 0
endif
int iResult = 0
form[] ddKeyArr
int iIndex = 0
form restraintsKey = Game.GetFormFromFile(0x01775f, "Devious Devices - Integration.esm")
if restraintsKey && restraintsKey.getType() == 45
iIndex += 1
else
restraintsKey = None
Debug.Trace("Simple Prostitution: [DD] Restraint key not found.")
endif
form chastityKey = Game.GetFormFromFile(0x008a4f, "Devious Devices - Integration.esm")
if chastityKey && chastityKey.getType() == 45
iIndex += 1
else
chastityKey = None
Debug.Trace("Simple Prostitution: [DD] Chastity key not found.")
endif
form piercingKey = Game.GetFormFromFile(0x0409a4, "Devious Devices - Integration.esm")
if piercingKey && piercingKey.getType() == 45
iIndex += 1
else
piercingKey = None
Debug.Trace("Simple Prostitution: [DD] Piercing key not found.")
endif
if iIndex == 0
return 0
endif
ddKeyArr = utility.createFormArray(iIndex)
While iIndex > 0
iIndex -= 1
if piercingKey && (ddKeyArr.find(piercingKey) < 0)
ddKeyArr[iIndex] = piercingKey
elseif chastityKey && (ddKeyArr.find(chastityKey) < 0)
ddKeyArr[iIndex] = chastityKey
elseif restraintsKey && (ddKeyArr.find(restraintsKey) < 0)
ddKeyArr[iIndex] = restraintsKey
endif
endWhile
int[] ddKeyNum = utility.createIntArray(ddKeyArr.Length, 0)
iIndex = 0
int jIndex
while iIndex < iNum
jIndex = Utility.RandomInt(0, ddKeyArr.Length - 1)
ddKeyNum[jIndex] = ddKeyNum[jIndex] + 1
iIndex += 1
endWhile
iIndex = ddKeyArr.Length
While iIndex > 0
iIndex -= 1
jIndex = ddKeyNum[iIndex]
if jIndex > 0
player.Additem(ddKeyArr[iIndex], jIndex)
iResult += jIndex
endif
EndWhile
return iResult
EndFunction

Event OnInit()
EndEvent

Expand Down Expand Up @@ -1850,7 +1785,7 @@ Auto State Init
endEvent

event OnEndState()
While (!FlowerGirlsInterface.bChecked || !SexLabInterface.bChecked || !OStimInterface.bChecked || !LicensesInterface.bChecked)
While (!FlowerGirlsInterface.bChecked || !SexLabInterface.bChecked || !OStimInterface.bChecked || !LicensesInterface.bChecked || !DDI_Interface.bChecked)
Utility.wait(0.2)
endWhile
;Debug.Trace("Simple Prostitution started.")
Expand Down Expand Up @@ -1900,7 +1835,6 @@ EndState

Bool function GetDibellanRewards(Int aiMessage=0, Int aiButton=0)
int iMarkCount = player.getItemCount(dibelMark)
bIsDDIntegrationActive = bCheckDDIntegeration()
utility.wait(0.5)
Bool bTraded = False
While true
Expand Down Expand Up @@ -1961,7 +1895,7 @@ Bool function GetDibellanRewards(Int aiMessage=0, Int aiButton=0)
DibelOfferMenu_InsufficientMark.Show(fDDKeyCost as Int, iMarkCount)
aiMessage = 0
elseif DibelOfferMenu_Confirm_DDKey.Show(fDDKeyCost as Int, fDDKeyIncrement as Int) == 0
int iTotal = iAddDeviousKeyToPlayer(fDDKeyIncrement as Int)
int iTotal = DDI_Interface.iAddRandomKeyToActor(player, fDDKeyIncrement as Int)
if iTotal > 0
MCMScript.iTotalDDKeyRecieved += iTotal
player.removeItem(dibelMark, fDDKeyCost as Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,21 @@ function setVars()
if !MainScript.LicensesInterface
MainScript.LicensesInterface = MainScript.LicensesInterfaceQst as zzzmrt_sp_licenses_interface
endif
if !MainScript.DDI_Interface
MainScript.DDI_Interface = MainScript.DDI_Interface as zzzmrt_sp_ddi_interface
endIf
MainScript.SexLabInterface.PlayerLoadsGame()
MainScript.OStimInterface.PlayerLoadsGame()
MainScript.FlowerGirlsInterface.PlayerLoadsGame()
MainScript.LicensesInterface.PlayerLoadsGame()
MainScript.DDI_Interface.PlayerLoadsGame()
MainScript.bIsPapyrusUtilActive = MainScript.bCheckPapyrusUtil()
MainScript.bIsPO3ExtenderActive = MainScript.bCheckPO3Extender()
Utility.Wait(10.0)
MainScript.bIsSexlabActive = MainScript.SexLabInterface.GetIsInterfaceActive()
MainScript.bIsOStimActive = MainScript.OStimInterface.GetIsInterfaceActive()
MainScript.bIsFlowerGirlsActive = MainScript.FlowerGirlsInterface.GetIsInterfaceActive()
MainScript.bIsLicensesActive = MainScript.LicensesInterface.GetIsInterfaceActive()
MainScript.bIsDDIntegrationActive = MainScript.DDI_Interface.GetIsInterfaceActive()
bBusy = False
endfunction
Binary file not shown.
Binary file added Simple Prostitution/Scripts/zzzmrt_sp_int_ddi.pex
Binary file not shown.
Binary file modified Simple Prostitution/Scripts/zzzmrt_sp_main_qst_script.pex
Binary file not shown.
Binary file modified Simple Prostitution/Scripts/zzzmrt_sp_player_qst_script.pex
Binary file not shown.
Binary file modified Simple Prostitution/mrt_SimpleProstitution.esp
Binary file not shown.

0 comments on commit 7342bbb

Please sign in to comment.