////////////////////////////////////////////////////////////////////////////// // // File : badge_act.skrit // Author(s): mcarp // // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // public definitions // reserved tags property bool _server_only$ = false; property string _doc$ = "Checks quest state upon receiving we_req_activate"; property string bamulet$; owner = GoSkritComponent; startup state Startup$ { transition -> FirstCheck$: OnGoHandleMessage( WE_ENTERED_WORLD ); } state FirstCheck$ { event OnEnterState$ { Go amuletInSlot$; Go parent$ = Owner.Go.Parent; amuletInSlot$ = parent$.Inventory.GetEquipped( ES_AMULET ); if (amuletInSlot$ != NULL) { if( StringTool.SameNoCase( amuletInSlot$.templatename, bamulet$)) { if (!Owner.Go.Aspect.IsVisible) { int k$ = 0; int kend$ = Owner.Go.Parent.Children.Size(); Go kamulet$; while( k$ < kend$ ) { kamulet$ = Owner.Go.Parent.Children.Get( k$ ); if( kamulet$ != NULL ) { if( StringTool.SameNoCase( kamulet$.templatename, bamulet$)) { Owner.Go.Parent.Aspect.AspectHandle.AttachRigidLinkedChild( kamulet$.Aspect.AspectHandle, "Bip01_Spine3", "grip_m_i_jmc_security-badge" ); Owner.Go.Aspect.SSetIsVisible(true); } } k$ += 1; } } } } SetState Using$; } } state Using$ { event OnEnterState$ { // Yup } event OnGoHandleMessage$( eWorldEvent e$, WorldMessage msg$ ) { if( e$ == WE_EQUIPPED ) { int i$ = 0; int iend$ = Owner.Go.Parent.Children.Size(); Go amulet$; while( i$ < iend$ ) { amulet$ = Owner.Go.Parent.Children.Get( i$ ); if( amulet$ != NULL ) { if( StringTool.SameNoCase( amulet$.templatename, bamulet$)) { Owner.Go.Parent.Aspect.AspectHandle.AttachRigidLinkedChild( amulet$.Aspect.AspectHandle, "Bip01_Spine3", "grip_m_i_jmc_security-badge" ); Owner.Go.Aspect.SSetIsVisible(true); } } i$ += 1; } report.screen ( "Badge Equipped" ); } else if( e$ == WE_UNEQUIPPED ) { int j$ = 0; int jend$ = Owner.Go.Parent.Children.Size(); Go uamulet$; while( j$ < jend$ ) { uamulet$ = Owner.Go.Parent.Children.Get( j$ ); if( uamulet$ != NULL ) { if( StringTool.SameNoCase( uamulet$.templatename, bamulet$)) { Goid uactuary$ = owner.Go.Parent.Goid; if (uactuary$ != NULL ) { uactuary$.Go.Aspect.AspectHandle.DetachChild( owner.Go.Aspect.AspectHandle ); Owner.Go.Aspect.SSetIsVisible(false); } else { report.screen( "Data1 == NULL" ); } } } j$ += 1; } report.screen ( "Badge Unequipped" ); } else { report.screenf ( "security badge heard we_ %d", e$ ); } } }