///////////////////////////////////////////////////////////////////////////// // // File : subanim_override.skrit // Author(s): Witness (Lisa Hui) // Purpose : override animation for a supported chore while this item is // equipped // History : v2.1 [November 6, 2004] // - added init delay for WE_WORLD_STATE_TRANSITION_DONE, because // attempts to access GoDb/quest bits before that causes a hard // crash // // v2.0 [September 10, 2004] // - centralizes animation overrides with a manager, which detects // property values of this component, so that overlapping // overrides can coexist // // v1.0 [September 4, 2004] // - sets quest bits cues for animation overrides // // //---------------------------------------------------------------------------- // Version: 2.1 Date: November 6, 2004 //---------------------------------------------------------------------------- ////////////////////////////////////////////////////////////////////////////// property eWorldEvent msg_activate$ = WE_UNKNOWN doc = ""; property eWorldEvent msg_deactivate$ = WE_UNKNOWN doc = ""; property string state_manager$ = "subanim_manager" doc = ""; property string state_name$ = "anim_override" doc = ""; property string state_description$ = "" doc = ""; property string attack_type$ = "" doc = ""; property int anim_attack$ = 0 doc = ""; property int anim_attack_min$ = -1 doc = ""; property int anim_attack_max$ = -1 doc = ""; property int anim_attack_fidget$ = -1 doc = ""; property int anim_fidget$ = 0 doc = ""; property int anim_fidget_min$ = -1 doc = ""; property int anim_fidget_max$ = -1 doc = ""; property int anim_walk$ = 0 doc = ""; property int anim_walk_min$ = -1 doc = ""; property int anim_walk_max$ = -1 doc = ""; owner = GoSkritComponent; startup State Init$ { event OnEnterState$ { if ( IsInGame( WorldState.CurrentState ) ) { SetState Listen$; } } transition -> Init$ : OnGoHandleMessage( WE_WORLD_STATE_TRANSITION_DONE ); } State Listen$ { Goid user$, manager$; bool update$; event OnEnterState$ { update$ = false; if ( anim_attack_min$ > 0 ) { anim_attack$ = ( anim_attack_min$ < anim_attack_max$ ? -2 : -1 ); } if ( anim_attack_fidget$ > -1 ) { update$ = true; } if ( anim_fidget_min$ > 0 ) { anim_fidget$ = ( anim_fidget_min$ < anim_fidget_max$ ? -2 : -1 ); update$ = true; } if ( anim_walk_min$ > 0 ) { anim_walk$ = ( anim_walk_min$ < anim_walk_max$ ? -2 : -1 ); update$ = true; } if ( !update$ ) { SetState Idle$; } } event OnGoHandleMessage$( eWorldEvent e$, WorldMessage /*msg*/ ) { if ( e$ == msg_activate$ ) { user$ = owner.Go.Parent.Goid; if ( !user$.IsValid ) { return; } if ( !user$.Go.HasActor() ) { user$ = Goid.InvalidGoid; return; } if ( user$.Go.Actor.HasGenericState( state_name$ ) ) { manager$ = user$.Go.Actor.GetGenericStateSpellGoid( state_name$ ); if ( !manager$.IsValid ) { GoCloneReq req$ = MakeGoCloneReq( state_manager$ ); req$.Omni = true; manager$ = GoDb.SCloneGo( req$ ); user$.Go.Actor.SRemoveGenericState( state_name$ ); user$.Go.Actor.SAddGenericState( state_name$, state_description$, 0.0, user$, manager$, 1.0 ); } } else { GoCloneReq req$ = MakeGoCloneReq( state_manager$ ); req$.Omni = true; manager$ = GoDb.SCloneGo( req$ ); user$.Go.Actor.SAddGenericState( state_name$, state_description$, 0.0, user$, manager$, 1.0 ); } PostWorldMessage( WE_REQ_ACTIVATE, owner.Goid, manager$, MakeInt( user$ ), 0.0 ); } else if ( e$ == msg_deactivate$ ) { if ( user$.IsValid ) { PostWorldMessage( WE_REQ_DEACTIVATE, owner.Goid, manager$, MakeInt( user$ ), 0.0 ); } } } } State Idle$ {}