Scriptname _00E_Game_Playerhouse_DocumentSC extends ObjectReference  

;=====================================================================================
;              							EVENTS                  					 
;=====================================================================================

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)

  if akNewContainer == PlayerREF && !bDone
	bDone = True
	_00E_NQ24_LeveledListHouse.Revert()
	VendorItemsBanker.RemoveAddedForm(VendorItemPropertyArk)
	_00E_NQ24_PlayerHouseOwned.SetValueInt(1)
	PlayerREF.AddItem(kyHouseKey, 1)
	objNoteRef.Disable()
	cHouseCell.SetActorOwner(PlayerREF.GetActorBase())
	sHouseName = NQ24.ChooseHouseName()
	If sHouseName == ""
		sHouseName = DefaultHouseName.GetName()
	EndIf
	cHouseCell.SetName(sHouseName)
	HouseBoardREF.Enable()
	
	If cHouseCell == CapitalCityPlayerhouse
		Player.sHouseMarketQuarterName = sHouseName
	ElseIf cHouseCell == CapitalCityPlayerHouseUpper
		Player.sHouseNobleQuarterName = sHouseName
	EndIf
	
	If !NQ24.IsCompleted()
		If !NQ24.IsRunning()
			NQ24.SetCurrentStageID(5)
			Utility.Wait(2)
			NQ24.SetCurrentStageID(10)
		Else
			NQ24.SetCurrentStageID(10)
		EndIf
	EndIf
	
  endIf
   
endEvent

;=====================================================================================
;              							PROPERTIES                  					 
;=====================================================================================

_00E_PlayerHousing_CellNameSC Property Player Auto

Actor Property PlayerREF Auto

bool bDone

Cell Property CapitalCityPlayerHouseUpper Auto
Cell Property CapitalCityPlayerhouse Auto

String Property sHouseName Auto

Message Property DefaultHouseName Auto

Cell Property cHouseCell Auto
{Set this to point at the cell the player will own from now on.}

Key Property kyHouseKey Auto
{Set this to point at the base object of the key which opens the door to the house}

ObjectReference Property objNoteRef Auto
{Set this to point to the ObjectReference of the note ACTIVATOR-SPHERE tucked at the door. Will be disabled.}

_00E_NQ24_Playerhousing_Functions Property NQ24 Auto

LeveledItem Property _00E_NQ24_LeveledListHouse Auto
{Set this to the respective LeveledItem for the document the player just purchased. Ensures that the document can't be purchased multiple times.}

GlobalVariable Property _00E_NQ24_PlayerHouseOwned Auto

FormList Property VendorItemsBanker Auto

Keyword Property VendorItemPropertyArk Auto

ObjectReference Property HouseBoardREF Auto
{Set this to the respective reference of the board, this property simply guarantees that the reference of the board is persistent.}