/* // Nuzzle Interaction // // caller needs to set up the following for both attacker and defender // action SetNumPassedParam(2) // action SetPassedParam(0, -1) */ ;// param 0: (int) behaviour, (-1 = init) ;// param 1: (float) seek dir, (-1.0f = left, 1.0f = right) machine Nuzzle { state Start { transition HasTarget() == false { goto NuzzleExit } action SetFlockImpulse(false) action StartLook("LookTarget", 0.5) action SetAutoMovementBlend(true) action SetSpeedModifierWalk(1.0) action SetRunMode(false) action SetStandStill() ;//action LockMachine(true) action LockMachine(false) transition InTargetProximityRadius(6.0, false) { goto MoveAwayFirst } transition { action SeekTarget(false, false) goto SeekProximity } } state MoveAwayFirst { transition SeekTargetOffset(9.0, 0.0, false, true, true) { action SetRandomTimerBetween(1, 20.0, 25.0) goto MoveAwayLoop } transition { action SeekTarget(false, false) goto SeekProximity } } state MoveAwayLoop { transition HasArrived() { action SeekTarget(false, false) goto SeekProximity } transition IsTimerUp(1) { action SeekTarget(false, false) goto SeekProximity } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < -1 { goto NuzzleExit } } state SeekProximity { transition InTargetProximityRadius(6.0, true) { action SetStandStill() action SetRandomTimerBetween(1, 20.0, 30.0) action SetPassedParam(0, 0) ;// ready to determine pos to seek to goto SyncPosSeek } transition HasArrived() { goto NuzzleExit } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < -1 { goto NuzzleExit } } state SyncPosSeek { transition IsTimerUp(1) { goto NuzzleExit ;// giveup } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) == 0 ;// seek towards target { direct goto SeekTry } transition GetPassedParamTarget(0) == 1 ;// wait for target to come { action SetPassedParam(0, 1) ;// face set direction action SeekSetDirection() goto SeekSetDirWait } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } } state SeekSetDirWait { transition HasArrived() { action SetPassedParam(0, 3) ;// ready to start nuzzling ;// action SetAvoidanceSteer(false) action SetRandomTimerBetween(1, 20.0, 25.0) goto PlayNuzzleSync } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } } state SeekTry { transition SetNuzzleTargetPos(5.0, false) { ;// action SetAvoidanceSteer(false) action SetPassedParam(0, 1) ;// ready to start seeking action SetRandomTimerBetween(1, 15.0, 20.0) action SeekSetPosition() goto NuzzleSeek } transition { goto NuzzleExit } } state NuzzleSeek { action SetNuzzleTargetPos(5.0, true) transition IsTimerUp(1) { goto NuzzleExit ;// giveup } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } transition InSetNuzzleProximity(0.7) { action SetStandStill() action SetPassedParam(0, 2) ;// ready to start facing alignment ;// action SetAvoidanceSteer(true) goto FacingWaitSync } transition HasArrived() { direct goto NuzzleSeekProxCheck } } state NuzzleSeekProxCheck { transition InSetNuzzleProximity(1.2) { action SetPassedParam(0, 2) ;// ready to start facing alignment ;// action SetAvoidanceSteer(true) goto FacingWaitSync } transition { action SetNuzzleTargetPos(5.0, true) action SeekSetPosition() goto NuzzleSeek } } state FacingWaitSync { transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } transition GetPassedParamTarget(0) == 2 { action FaceTargetsFacing() goto FaceTargetWait } transition GetPassedParamTarget(0) == 3 { action FaceTargetsFacing() goto FaceTargetWait } } state FaceTargetWait { transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } transition HasArrived() { action SetPassedParam(0, 3) ;// ready to start nuzzling action SetRandomTimerBetween(1, 20.0, 25.0) goto PlayNuzzleSync } } state PlayNuzzleSync { transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) == 3 { ;// action SetAvoidanceSteer(true) goto PlayNuzzle } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } transition IsTimerUp(1) { goto NuzzleExit } } state PlayNuzzle { action SetSpeedDirect(0.0) action SetStandStill() action StopLook() action SetRandomTimerBetween(1, 2.0, 2.0) transition { goto BeginNuzzlePause } } state BeginNuzzlePause { transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } transition IsTimerUp(1) { goto BeginNuzzle } } state BeginNuzzle { action SetAutoMovementBlend(false) transition IsTargetOnLeft() { action PlayAnimInstant("spcl", "nuz_lt", false) goto PlayNuzzleWait } transition { action PlayAnimInstant("spcl", "nuz_rt", false) goto PlayNuzzleWait } } state PlayNuzzleWait { transition IsAnimStatePlaying("spcl") == false { goto PlayNuzzle2 } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } } state PlayNuzzle2 { transition IsTargetOnLeft() { action PlayAnimInstant("spcl", "nuz_lt", false) goto PlayNuzzleWaitLast } transition { action PlayAnimInstant("spcl", "nuz_rt", false) goto PlayNuzzleWaitLast } } state PlayNuzzleWaitLast { transition IsAnimStatePlaying("spcl") == false { action SetRandomTimerBetween(1, 1.0, 5.0) action SetAutoMovementBlend(true) goto NuzzleFinCall } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } } state NuzzleFinCall { transition IsTimerUp(1) { action PlayAnim("call", "02_lp", false) action SetRandomTimerBetween(1, 2.0, 3.0) goto NuzzleFinPause } } state NuzzleFinPause { transition IsTimerUp(1) { goto NuzzleExit } transition GetNumPassedParamTarget() != 2 { goto NuzzleExit } transition GetPassedParamTarget(0) < 0 { goto NuzzleExit } } ;//----------------------------------------------------------------- exitstart state NuzzleExit { action StopLook() action SetPassedParam(0, -2) transition IsAnimStatePlaying("spcl") { goto NuzzAnimWait } transition { goto NuzzleExitEnd } } state NuzzAnimWait { transition IsAnimStatePlaying("spcl") == false { action SetAutoMovementBlend(true) goto NuzzleExitEnd } } exitend state NuzzleExitEnd { action SetPassedParam(0, -2) action StopAnimInstant("spcl", "nuz_lt") action StopAnimInstant("spcl", "nuz_rt") action SetAutoMovementBlend(true) action SetFlockImpulse(true) action SetInterpolation(false) ;// action SetAvoidanceSteer(true) action SetLockFacing(false) action SetWalkBackMode(false) action LockMachine(false) action DeleteAllCommands() } }