4
Fork 0

Reverted weapon rack script to vanilla

remove-levelsystem
Eddoursul 4 months ago
parent 64d89d4dae
commit 7b8b070737
  1. BIN
      scripts/uskpwrplayeraliasscript.pex
  2. BIN
      scripts/weaponrackactivatescript.pex
  3. BIN
      scripts/weaponracktriggerscript.pex
  4. 73
      source/scripts/uskpwrplayeraliasscript.psc
  5. 1017
      source/scripts/weaponrackactivatescript.psc
  6. 285
      source/scripts/weaponracktriggerscript.psc

@ -1,73 +0,0 @@
Scriptname USKPWRPlayerAliasScript extends ReferenceAlias
;by taleden - 2013-10-28
;by taleden - rev 4 (2013-11-01)
Bool bDropActive = False
Form kDropForm = None
ObjectReference kDropRef = None
Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
EndEvent
;/~~~
Event OnPlayerLoadGame() ;TODO
Actor player = Game.GetPlayer()
; player.AddItem(Game.GetForm(0xF), 50000) ; gold
player.AddItem(Game.GetForm(0x09fd50)) ; Red Eagle's Fury
player.AddItem(Game.GetForm(0x10c6fb), 5); Silver Greatsword
player.AddItem(Game.GetForm(0x10aa19), 5); Silver Sword
player.AddItem(Game.GetForm(0x0956b5)) ; Wuuthrad
; player.AddItem(Game.GetForm(0x10f601) As ObjectReference) ; Borvir's Dagger (JourneymansNookExterior01)
; player.AddItem(Game.GetForm(0x0f3248) As ObjectReference) ; Bow of the Hunt (ClearspringTarn01)
player.AddItem(Game.GetForm(0x08adfd) As ObjectReference) ; Ceremonial Axe (Volunruud01)
; player.AddItem(Game.GetForm(0x031160) As ObjectReference) ; Dwarven Battleaxe (MarkarthWizardsQuarters01)
; player.AddItem(Game.GetForm(0x0c19fe) As ObjectReference) ; Dwarven Sword of Arcing (MarkarthWizardsQuarters01)
player.AddItem(Game.GetForm(0x04a39d) As ObjectReference) ; Ebony Blade (WhiterunDragonsreach)
(Game.GetForm(0x094a2c) As ObjectReference).Enable()
player.AddItem(Game.GetForm(0x094a2c) As ObjectReference) ; Ghostblade (Ansilvund02)
(Game.GetForm(0x10e94c) As ObjectReference).Enable()
player.AddItem(Game.GetForm(0x10e94c) As ObjectReference) ; Keening (WinterholdCollegeHallofCountenance)
; player.AddItem(Game.GetForm(0x10f904) As ObjectReference) ; Rundi's Dagger (POINorthernCoast16)
(Game.GetForm(0x02e526) As ObjectReference).Enable()
player.AddItem(Game.GetForm(0x02e526) As ObjectReference) ; Volendrung (LargasburExterior04)
EndEvent
;/~~~/;
State active
Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)
; Debug.Trace(Self + ".OnItemRemoved("+akBaseItem+", "+aiItemCount+", "+akItemReference+", "+akDestContainer+")")
If bDropActive && (akBaseItem == kDropForm) && (akDestContainer == None)
GotoState("")
bDropActive = False
kDropRef = akItemReference
EndIf
EndEvent ; OnItemRemoved()
EndState ; active
ObjectReference Function DropPlayerItem(Form akItem, Int aiRetries = 100)
Actor player = GetActorReference()
player.UnequipItem(akItem, False, True)
bDropActive = True
kDropForm = akItem
kDropRef = None
GotoState("active")
player.DropObject(akItem, 1)
Int try = aiRetries
While (try > 0) && bDropActive
try -= 1
Utility.Wait(0.01) ; one frame draw, unless fps>100
EndWhile
GotoState("")
ObjectReference ref = kDropRef
bDropActive = False
kDropForm = None
kDropRef = None
; Debug.Trace(Self + ".DropPlayerItem() looped "+(aiRetries-try)+" times, returning "+ref)
Return ref
EndFunction ; DropPlayerItem()

File diff suppressed because it is too large Load Diff

@ -1,20 +1,14 @@
Scriptname WeaponRackTriggerSCRIPT extends ObjectReference Hidden
;Modifications by Sclerocephalus - debug version 3.4 (10/21/2013)
;modified by taleden - rev 4 (2013-11-01)
;Modifications by DayDreamer - version 5.0 (2014 Mar 15)
Scriptname WeaponRackTriggerSCRIPT extends ObjectReference Hidden
import game
import debug
import utility
;-------------------------------------------
Keyword Property WRackActivator Auto
;The activator we must disable if there is already something in this trigger
ObjectReference Property ActivatorRef Auto Hidden
;///
;Reference that is currently in the trigger
ObjectReference Property RefCurrentlyInTrig Auto Hidden
@ -22,238 +16,87 @@ ObjectReference Property RefCurrentlyInTrig Auto Hidden
Bool Property HasBeenTriggered Auto Hidden
Int Property numInTrig Auto Hidden
///;
Bool Property AlreadyInit Auto Hidden
Bool Property IgnoreArmor = FALSE Auto
;-------------------------------------------
;*** USKP Properties ***
Keyword Property ArmorShield Auto
;-------------------------------------------
;*** USKP Variables ***
WeaponRackActivateScript ActivatorScript = None
;/------------------------------------------
Handle mis-configured triggers.
Returns False for success.
/;
Bool Function CheckConfiguration(String CallingEvent)
GoToState("ActivatorBusy")
If WRackActivator == None
; script was deleted, properties missing
;~ Trace(Self + CallingEvent + "() CHECK: WRackActivator == None; 'ActivatorBusy' state.")
Return True
EndIf
ActivatorRef = GetLinkedRef(WRackActivator)
If ActivatorRef == Self
; hand fixed, don't disable
;~ Trace(Self + CallingEvent + "() CHECK: WRackActivator == Self; 'ActivatorBusy' state.")
ActivatorRef = None
Return True
EndIf
If ActivatorRef == None
Trace(Self + CallingEvent + "() ERROR: missing WRackActivator; 'ActivatorBusy' state.")
Return True
EndIf
ActivatorScript = ActivatorRef As WeaponRackActivateScript
If ActivatorScript == None
Trace(Self + CallingEvent + "() ERROR: missing WeaponRackActivateScript; 'ActivatorBusy' state.")
ActivatorRef = None
Return True
EndIf
If isDisabled()
GoToState("TriggerDisabled")
ActivatorRef.DisableNoWait()
;~ Trace(Self + CallingEvent + "() CHECK: is disabled; set 'TriggerDisabled' state; " + ActivatorRef + " disabled too.")
ActivatorRef = NONE
ActivatorScript = NONE
Return True
EndIf
Return False
EndFunction
;-------------------------------------------
EVENT OnCellDetach(); replace OnReset()
EVENT OnReset()
AlreadyInit = FALSE
;Trace("DARYL - " + self + " running OnReset() and AlreadyInit = " + AlreadyInit)
endEVENT
;/------------------------------------------
This event must be present to catch extant USKP 2.0.0 racks,
or otherwise without known state.
This is present solely for backward compatibility.
/;
EVENT OnCellAttach(); replace OnCellLoad()
TriggerSetup("Trigger:OnCellAttach")
EVENT OnLoad()
;Trace("DARYL - " + self + " running OnLoad() and AlreadyInit = " + AlreadyInit)
if (AlreadyInit == FALSE) && (self.IsEnabled())
ActivatorRef = GetLinkedRef(WRackActivator)
if (ActivatorRef)
ActivatorRef.Enable()
endif
ActivatorRef = NONE
AlreadyInit = TRUE
;Trace("DARYL - " + self + " The Activator Ref is " + ActivatorRef)
else
;Do nothing
endif
;Trace("DARYL - " + self + " finishing OnLoad() and AlreadyInit = " + AlreadyInit)
endEVENT
;/------------------------------------------
This state must be present to catch extant USKP 1.3.3 racks.
(1) The activator is known to be missing, but can be resuscitated.
(2) The activator status is currently being tested. Suppress redundant
OnLoad() and trigger events.
(3) The activator is either enabled (and the rack empty, so the trigger
won't be needed anyway) or running a placement procedure. OnTriggerLeave()
events during placement are from adjacent racks ("cross-activation") or
from a temporary loss of the item's 3D during a MoveToNode command.
Skip them to prevent the items from being mis-interpreted as having been
grabbed from the rack.
/;
STATE ActivatorBusy
EVENT OnCellAttach()
endEVENT
EVENT OnLoad()
endEVENT
EVENT OnTriggerLeave(ObjectReference ItemRef)
;~ Trace(Self + "ActivatorBusy:OnTriggerLeave() " + ItemRef + "; Base = " + ItemRef.GetBaseObject())
endEVENT
endSTATE
;/------------------------------------------
This state must be present to catch extant USKP 2.0.1 racks.
The activator has been detected by OnCellAttach(), this trigger is
currently disabled. Allows OnLoad() to setup.
/;
STATE TriggerDisabled
EVENT OnCellAttach()
endEVENT
;/ Catch newly enabled racks with player present.
Starting items must be done upon constructing the rack at a
workbench in a player home. OnCellAttach() does not fire.
/;
EVENT OnLoad()
If Self == None
Trace(Self + "OnLoad() ERROR!")
return
EndIf
;EVENT OnCellLoad()
; ;Trace("DARYL - " + self + " running OnCellLoad() and AlreadyInit = " + AlreadyInit)
; if (AlreadyInit == FALSE) && (self.IsEnabled())
; ActivatorRef = GetLinkedRef(WRackActivator)
; AlreadyInit = TRUE
; ;Trace("DARYL - " + self + " The Activator Ref is " + ActivatorRef)
; else
; ;Do nothing
; endif
; ;Trace("DARYL - " + self + " finishing OnCellLoad() and AlreadyInit = " + AlreadyInit)
;endEVENT
Cell parentCell = GetParentCell()
If parentCell == None
Trace(Self + "OnLoad() ERROR: GetParentCell == None")
return
EndIf
If !parentCell.IsAttached()
Trace(Self + "OnLoad() ERROR: parentCell=" + parentCell + " !IsAttached()")
return
EndIf
TriggerSetup("TriggerDisabled:OnLoad")
endEVENT
EVENT OnTriggerLeave(ObjectReference ItemRef)
;~ Trace(Self + "TriggerDisabled:OnTriggerLeave() " + ItemRef + "; Base = " + ItemRef.GetBaseObject())
endEVENT
endSTATE
;/------------------------------------------
This is a vanilla state and must be present to catch extant vanilla racks.
However, the contents have been significantly revised.
/;
auto STATE WaitingForReference
;/ Catch newly enabled racks without player present.
Previously placed items must be renewed on every cell attach,
re-adjusting to current game mesh defined nodes.
/;
EVENT OnCellAttach()
TriggerSetup("WFR:OnCellAttach")
endEVENT
EVENT OnLoad()
EVENT onTriggerEnter(objectReference triggerRef)
;Trace("DARYL - " + self + " Just OnTriggerEntered by " + triggerref)
if (IgnoreArmor == TRUE) && (triggerRef.GetBaseObject() as Armor)
;Trace("DARYL - " + self + " I'm ignoring armor, and this is armor, so I'm doing nothing.")
;Do Nothing
else
;Trace("DARYL - " + self + " I'm updating as normal")
;numInTrig = (numInTrig + 1)
HasBeenTriggered = TRUE
ActivatorRef = GetLinkedRef(WRackActivator)
if ActivatorRef
ActivatorRef.Disable()
endif
ActivatorRef = NONE
endif
endEVENT
;/ It would be nice if we could filter out spurious events fired by bouncing
clutter etc, but we can't call any native methods on triggerRef such as
GetBaseObject() -- if the retrieved item was scripted, then by the time
this runs it may already be in the player's inventory and our pointer
will be broken. So we'll have to make do with just comparing the pointer
itself to our other stored pointers. --taleden
/;
EVENT OnTriggerLeave(objectReference triggerRef)
;Trace("DARYL - " + self + " A References has EXITED, refs in this trigger now = " + numInTrig)
if (IgnoreArmor == TRUE) && (triggerRef.GetBaseObject() as Armor)
;Trace("DARYL - " + self + " I'm ignoring armor, and this is armor, so I'm doing nothing.")
;Do Nothing
else
;Trace("DARYL - " + self + " I'm updating as normal")
;numInTrig = (numInTrig - 1)
endif
if (GetTriggerObjectCount() == 0)
ActivatorRef = GetLinkedRef(WRackActivator)
HasBeenTriggered = FALSE
ActivatorRef.Enable()
If CheckConfiguration("WFR:OnTriggerLeave")
return
EndIf
; state ActivatorBusy
If !ActivatorRef.IsDisabled()
;~ Trace(Self + "OnTriggerLeave() CHECK: activator was enabled; 'ActivatorBusy' state.")
ActivatorRef = NONE
ActivatorScript = NONE
return
EndIf
If ActivatorScript.RackWasTriggered(triggerRef, GetTriggerObjectCount())
GoToState("WaitingForReference")
;~ Trace(Self + "OnTriggerLeave() retain 'WaitingForReference' state.")
EndIf
ActivatorRef = NONE
ActivatorScript = NONE
endif
endEVENT
endSTATE
;/------------------------------------------
TriggerSetup() CheckConfiguration() immediately changes state,
suppressing OnLoad() and trigger events.
Called from OnLoad() and OnCellAttach() both here and there.
/;
Function TriggerSetup(String CallingEvent)
Bool wasHandled = AlreadyInit
AlreadyInit = True
If wasHandled
;~ Trace(Self + CallingEvent + "() TriggerSetup() was handled.")
Return
EndIf
If CheckConfiguration(CallingEvent)
Return
EndIf
; state ActivatorBusy
;~ Trace(Self + CallingEvent + "() " + ActivatorRef + " update setup.")
ActivatorScript.ActivatorSetup(CallingEvent)
ActivatorRef = NONE
ActivatorScript = NONE
EndFunction

Loading…
Cancel
Save