LordRethan Posted June 6, 2020 Share Posted June 6, 2020 I am working on someone's player home mod with a drawbridge.The problem is that the drawbridge is closed/raised by default.This causes issues with traveling NPCs especially patrol mods like e.g. Horses on Patrol.It has to be open/lowered on default.I have no idea how to edit the script (I tried to switch the states but that did not help) to achieve that.Please help.This is the script: import utility Keyword Property LinkCustom01 AutoObjectReference Property Drawbridge Auto Hidden EVENT OnLoad()Wait(3)Drawbridge = GetLinkedRef()Drawbridge.PlayGamebryoAnimation("Forward", true)GoToState("ReadyForOpen")endEVENt State ReadyForOpenEvent onActivate(ObjectReference TriggerRef)GoToState("Busy")Drawbridge.PlayGamebryoAnimation("Backward", true)Wait(3)GoToState("ReadyForClose")EndEventEndState State ReadyForCloseEvent onActivate(ObjectReference TriggerRef)GoToState("Busy")Drawbridge.PlayGamebryoAnimation("Forward", true)Wait(3)GoToState("ReadyForOpen")EndEventEndState State Busy;Empty StateEndState Link to comment Share on other sites More sharing options...
Ghaunadaur Posted June 6, 2020 Share Posted June 6, 2020 If it should be opened by default, change the OnLoad event to this: EVENT OnLoad() Wait(3) Drawbridge = GetLinkedRef() Drawbridge.PlayGamebryoAnimation("Backward", true) GoToState("ReadyForClose") endEVENt Link to comment Share on other sites More sharing options...
ReDragon2013 Posted June 6, 2020 Share Posted June 6, 2020 vanilla script is WRDrawBridge01SCRIPT Scriptname WRDrawBridge01SCRIPT extends ObjectReference {Handles the animation of the Whiterun Drawbridge.} import game import debug import utility import quest Keyword Property LinkCustom01 Auto Keyword Property LinkCustom02 Auto ObjectReference Property Drawbridge Auto Hidden ObjectReference Property Collision Auto Hidden ObjectReference Property PartnerLever Auto Hidden Quest Property CWSiege Auto EVENT OnLoad() Wait(3) Drawbridge = GetLinkedRef() Collision = GetLinkedRef(LinkCustom01) PartnerLever = GetLinkedRef(LinkCustom02) endEVENt STATE ReadyForClose EVENT onActivate(ObjectReference TriggerRef) if (CWSiege as CWSiegeScript).IsAttack() Drawbridge.PlayGamebryoAnimation("Forward", TRUE) Collision.Enable() GoToState("Done") else if TriggerRef == GetPlayer() ; Player cannot activate this on defense else Drawbridge.PlayGamebryoAnimation("Forward", TRUE) Collision.Enable() GoToState("Done") endif endif endEVENT endSTATE AUTO STATE ReadyForOpen EVENT onActivate(ObjectReference TriggerRef) if (CWSiege as CWSiegeScript).IsAttack() Drawbridge.PlayGamebryoAnimation("Backward", TRUE) Collision.Disable() GoToState("Done") else if TriggerRef == GetPlayer() ; Player cannot activate this on defense else Drawbridge.PlayGamebryoAnimation("Backward", TRUE) Collision.Disable() (PartnerLever as WRDrawBridge01SCRIPT).GoToState("Done") GoToState("Done") endif endif endEVENT endSTATE STATE Done EVENT OnBeginState() self.Disable() PartnerLever.Disable() endEvent endSTATE You should make your own script to minimize gaming issues for example with civil war. Maybe script as follow:xyzDrawBridgeSCRIPT Scriptname xyzDrawBridgeSCRIPT extends ObjectReference {Handles the animation of the Whiterun Drawbridge.} ; https://forums.nexusmods.com/index.php?/topic/8786473-need-help-with-drawbridge-script/ Keyword PROPERTY LinkCustom01 auto Keyword PROPERTY LinkCustom02 auto ;ObjectReference Property Drawbridge auto Hidden ; UnUSED ;ObjectReference Property Collision auto Hidden ; UnUSED ;ObjectReference Property PartnerLever auto Hidden ; UnUSED ; -- EVENTs -- 1 + "ReadyForOpen" + "Done" + "ReadyForClose" EVENT OnLoad() Utility.Wait(3.0) IF self.IsDisabled() ; already disabled ELSE gotoState("ReadyForOpen") OnActivate( Game.GetPlayer() as ObjectReference ) ; fake player activation ENDIF ;;; Drawbridge = self.GetLinkedRef() ;;; Collision = self.GetLinkedRef(LinkCustom01) ;;; PartnerLever = self.GetLinkedRef(LinkCustom02) ENDEVENT ;============================= auto state ReadyForOpen ; default state for activation, because of "AUTO" keyword ;====================== EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not player activated ENDIF ; ---------------------- objectReference oRef oRef = self.GetLinkedRef() oRef.PlayGamebryoAnimation("Backward", TRUE) ; oRef = DrawBridge oRef = self.GetLinkedRef(LinkCustom01) oRef.Disable() ; oRef = Collision self.Disable() ; disable this lever myF_Partner(TRUE) gotoState("Done") ; ### STATE ### triggers OnBeginState() event ENDEVENT ;======= endState ;============================= STATE Done ; both levers use this state and wait time within the begin event ;========= EVENT OnBeginState() Utility.Wait(10.0) ; wait long enough, until drawbridge can be IF self.IsDisabled() self.Enable() gotoState("ReadyForClose") ; re-closed ELSE gotoState("ReadyForOpen") ; re-opened ENDIF ENDEVENT ;======= endState ;============================= STATE ReadyForClose ;================== EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not player activated ENDIF ; ---------------------- objectReference oRef oRef = self.GetLinkedRef() oRef.PlayGamebryoAnimation("Forward", TRUE) ; oRef = DrawBridge oRef = self.GetLinkedRef(LinkCustom01) oRef.Enable() ; oRef = Collision myF_Partner(False) gotoState("Done") ; ### STATE ### triggers OnBeginState() event ENDEVENT ;======= endState ; -- FUNCTION -- ;----------------------------- FUNCTION myF_Partner(Bool bOK) ;----------------------------- ; the drawbridge may have two levers, if one lever has been activated (self) the other lever should go down also xyzDrawBridgeSCRIPT ps = self.GetLinkedRef(LinkCustom02) as xyzDrawBridgeSCRIPT IF ( ps ) IF ( bOK ) (ps as ObjectReference).Disable() ; disable the other lever ENDIF ps.gotoState("Done") ; oRef = PartnerLever ENDIF ENDFUNCTION Link to comment Share on other sites More sharing options...
LordRethan Posted June 8, 2020 Author Share Posted June 8, 2020 Thank you very much. Works like a charm now. Link to comment Share on other sites More sharing options...
Recommended Posts