TobiaszPL Posted April 10, 2019 Share Posted April 10, 2019 (edited) Heyyyyy.... Class ;class QChain{ // WIP :: Version 6 :: ;private: // Don't edit my Class ok? ;struct QItemST{ sry but i have to edit this T_T int NextID, PrevID; int Value; ;}*Item; int FirstID, LastID; int LastUsed; int AMT; int Size; ;struct QFreeST{ int First; ;int *List; ;}Free; ;Created With QLG Machine ;Struct int ;EndStruct ;public: ;Deleted 14 Functions ;int GetID(){ ; return LastUsed;} ;int GetValueAt( int ID ){ ; return Item[ ID ].Value; } ;int GetNextAt( int ID ){ ; return Item[ ID ].NextID; } ;int GetPrevAt( int ID ){ ; return Item[ ID ].PrevID; } ;int GetSize(){ return Size; } ;int GetAmount(){ return AMT; } ;int GetLastID(){ return LastID; } ;int GetFirstID(){ return FirstID; } ;bool Add( int NewValue ) ;{ ; if( AMT == Size )return false; ; ; int NewItemID = Free.List[ Free.First ]; ; Item[ FirstID ].PrevID = NewItemID; ; Item[ LastID ].NextID = NewItemID; ; Item[ NewItemID ].NextID = FirstID; ; Item[ NewItemID ].PrevID = LastID; ; Item[ NewItemID ].Value = NewValue; ; LastID = NewItemID; ; ; Free.First--; ; AMT++; ; ; return true; ;} ;bool RemoveID( int ID ) ;{ ; if( AMT == 0 )return false; ; int ItemID = FirstID; ; for(int i=0;i<AMT;i++) ; { ; if( ID == ItemID ) ; { ; Free.First++; ; Free.List[ Free.First ] = ID; ; Item[ Item[ ItemID ].PrevID ].NextID = Item[ ItemID ].NextID; ; Item[ Item[ ItemID ].NextID ].PrevID = Item[ ItemID ].PrevID; ; ; if( ItemID == FirstID ) ; FirstID = Item[ ItemID ].NextID; ; ; if( ItemID == LastID ) ; LastID = Item[ ItemID ].PrevID; ; ; AMT--; ; ; return true; ; } ; ItemID = Item[ ItemID ].NextID; ; } ;return false; ;} ;QChain(int iSize=32) ;{ ; Size = iSize; ; ; Item = new QItemST[ Size ]; ; Free.List = new int[ Size ]; ; Free.First = Size-1; ; ; for( int i=0; i<Size; i++) ; { ; Free.List[i] = ( Size - i ) - 1 ; ; Item[i].NextID = 0; ; Item[i].PrevID = 0; ; Item[i].Value = 1; ; } ; ; AMT = 0; ; LastUsed = 0; ; FirstID = 0; ; LastID = 0; ; ; ;} its Version 6 and its my bad cause most updated version is 8 xDbut now i have few free days of work so i can't get good class version :c i have to work on old xD here is script you help me making earlier Scriptname QLG_Script_SwitchLight extends ObjectReference { } ;===- Base Info. -===; ;Created: 2019-03-17 ;Update: 2019-04-02 ;Author: TobiPL ;Unit: M.PC<3> ;===- Var. setup -============================================ ;===- Items Var. === FormList Property QLights auto { List of Used Lights } FormList Property QStatic auto { List of Used Static Meshes } FormList Property QLightH Auto { List of Used Light House Effects } Sound Property QSoundOn Auto { Sound to Play on fire activate } Sound Property QSoundOff Auto { Sound to Play on fire deactivate } Bool Property QPlayerOnly auto { If set to True only Player can Activate Script } ;===- TurnOff Var. === Float Property QTurnOffDelay auto { Time in Game Hours after Light go off : Set this to 0 for random !... : Value 0.5 mean 30 Game Min !... } Int Property QTurnOffAMT auto { This value decide how many lights go off each refresh } Bool Property QTurnOff auto { If this set to True Lights go off after time } Bool Property QAllowRe auto { Set this value to True if Lights should Turn ON Once Player Enter this same Trigger Again } Bool QIsBussy = false ; Only for Time Regiesters // Do not change !... Int QLightsLeft = 0 ; Control how many lights left to Turn off ;========================================================== Bool QIsDataLoaded = false ObjectReference[] QArrayLights ObjectReference[] QArrayLightH ObjectReference[] QArrayStatic ;========================================================== Function QLDataLoad() int i = QLights.GetSize() QArrayLights = new ObjectReference[ i ] QArrayLightH = new ObjectReference[ i ] QArrayStatic = new ObjectReference[ i ] While ( i > 0 ) i -= 1 QArrayLights = QLights.GetAt( i ) QArrayLightH = QLightH.GetAt( i ) QArrayStatic = QStatic.GetAt( i ) EndWhile QIsDataLoaded = true EndFunction ;========================================================== ;===- Script -Main- -================================================ Event OnInit() If ( QIsBussy ) GoToState( "QState_Bussy" ) Else GoToState( "QState_Waiting" ) QL_TurnLightsOff() QLightsLeft = 0 QIsBussy = false EndIf EndEvent ;==================================================================== ;class QChain{ // WIP :: Version 6 :: ;private: // Don't edit my Class ok? ;struct QItemST{ sry but i have to edit this T_T int NextID, PrevID; int Value; ;}*Item; int FirstID, LastID; int LastUsed; int AMT; int Size; ;struct QFreeST{ int First; ;int *List; ;}Free; ;Created With QLG Machine ;Struct int ;EndStruct ;public: ;Deleted 14 Functions ;int GetID(){ ; return LastUsed;} ;int GetValueAt( int ID ){ ; return Item[ ID ].Value; } ;int GetNextAt( int ID ){ ; return Item[ ID ].NextID; } ;int GetPrevAt( int ID ){ ; return Item[ ID ].PrevID; } ;int GetSize(){ return Size; } ;int GetAmount(){ return AMT; } ;int GetLastID(){ return LastID; } ;int GetFirstID(){ return FirstID; } ;bool Add( int NewValue ) ;{ ; if( AMT == Size )return false; ; ; int NewItemID = Free.List[ Free.First ]; ; Item[ FirstID ].PrevID = NewItemID; ; Item[ LastID ].NextID = NewItemID; ; Item[ NewItemID ].NextID = FirstID; ; Item[ NewItemID ].PrevID = LastID; ; Item[ NewItemID ].Value = NewValue; ; LastID = NewItemID; ; ; Free.First--; ; AMT++; ; ; return true; ;} ;bool RemoveID( int ID ) ;{ ; if( AMT == 0 )return false; ; int ItemID = FirstID; ; for(int i=0;i<AMT;i++) ; { ; if( ID == ItemID ) ; { ; Free.First++; ; Free.List[ Free.First ] = ID; ; Item[ Item[ ItemID ].PrevID ].NextID = Item[ ItemID ].NextID; ; Item[ Item[ ItemID ].NextID ].PrevID = Item[ ItemID ].PrevID; ; ; if( ItemID == FirstID ) ; FirstID = Item[ ItemID ].NextID; ; ; if( ItemID == LastID ) ; LastID = Item[ ItemID ].PrevID; ; ; AMT--; ; ; return true; ; } ; ItemID = Item[ ItemID ].NextID; ; } ;return false; ;} ;QChain(int iSize=32) ;{ ; Size = iSize; ; ; Item = new QItemST[ Size ]; ; Free.List = new int[ Size ]; ; Free.First = Size-1; ; ; for( int i=0; i<Size; i++) ; { ; Free.List[i] = ( Size - i ) - 1 ; ; Item[i].NextID = 0; ; Item[i].PrevID = 0; ; Item[i].Value = 1; ; } ; ; AMT = 0; ; LastUsed = 0; ; FirstID = 0; ; LastID = 0; ; ; ;} ; State - Waiting for player to enter Trigger State QState_Waiting Event OnTriggerEnter( ObjectReference QRef ) ;If ( !QPlayerOnly ) ; Return ;EndIf If ( QTurnOffDelay <= 1 ) RegisterForSingleUpdateGameTime( Utility.RandomInt( 0 , 120 ) ) Else RegisterForSingleUpdateGameTime( QTurnOffDelay ) EndIf QL_TurnLightsON() QIsBussy = true GoToState( "QState_Bussy" ) EndEvent EndState ; State - ights Activated, waiting to Turn them OFF or Enter Player State QState_Bussy Event OnTriggerEnter( ObjectReference QRef ) If ( QAllowRe ) QL_TurnLightsON() Else ; Do Nothing if already working ; Or Write anything You want EndIf EndEvent EndState ; Event on Game Time - Turn off few lights etc. Event OnUpdateGameTime() QL_TurnFewLightsOff() If ( QLightsLeft <= 0 ) GoToState( "QState_Waiting" ) QLightsLeft = 0 QIsBussy = false UnregisterForUpdateGameTime() Else If ( QTurnOffDelay <= 1 ) RegisterForSingleUpdateGameTime( Utility.RandomInt( 0 , 120 ) ) Else RegisterForSingleUpdateGameTime( QTurnOffDelay ) EndIf EndIf EndEvent Event OnCellDetach() QL_TurnLightsOff() QLightsLeft = 0 QIsBussy = false GoToState( "QState_Waiting" ) EndEvent ;==================================================================== Function QL_TurnFewLightsON() EndFunction ;===- Turn Lights ON -===; Function QL_TurnLightsON() ; Get Data Ready int I = QLights.GetSize() QLightsLeft = I While ( I >=0 ) I -= 1 ( QLights.GetAt(I) as ObjectReference ).Enable( true ) ( QStatic.GetAt(I) as ObjectReference ).Enable( true ) EndWhile EndFunction ; Special value for TurnOffLighsts Functions Int ReFreshLimit = 32 ; Limit for ReFresh ; After this time Lights goes off Function QL_TurnFewLightsOff() int I = QLights.GetSize() int Loop = 0 int Random = 0 While ( Loop < QTurnOffAMT ) Random = Utility.RandomInt( 0 , I ) If ( ( QLights.GetAt( Random ) as ObjectReference ).IsEnabled() ) ( QLights.GetAt( Random ) as ObjectReference ).Disable( true ) ( QStatic.GetAt( Random ) as ObjectReference ).Disable( true ) EndIf Utility.Wait( 2.3 ) Loop += 1 EndWhile ReFreshLimit -= 1 If ( ReFreshLimit <=0 ) QL_TurnLightsOFF() EndIf EndFunction Function QL_TurnLightsOff() int I = QLights.GetSize() QLightsLeft = 0 While ( I >=0 ) I -= 1 ( QLights.GetAt(I) as ObjectReference ).Disable( true ) ( QStatic.GetAt(I) as ObjectReference ).Disable( true ) EndWhile EndFunction y i know my code is perfect :3 what this class do?Its Array like Chain so one objects is connected with next and prev "chain eye"we can easly delete and create new "chain eyes" i want this class to control how many Lights still left to Outalso i want this class to Manage every object in Script i know my code is very long and... well not very easy to readbut if any1 have time and want to help me im w8ing and also trying to make this class in CK :D in C++ it was tested and working fine but like i said i copied Version 6 not 8 so there may be stillsome bad functions, also i delete many functions im not gonna need but i read this classand im prety sure i dont delete anything that is need What this script have to do?1) Turn ALL Lights if Player Enter TriggerBox2) Wait 1 hour and Turn Off few Lights3) If All lights Off Disable and wait for Player sry 4 my english and ty for help :smile: Edited April 10, 2019 by TobiaszPL Link to comment Share on other sites More sharing options...
Recommended Posts