#--------------------------------------------- # Start state #--------------------------------------------- state Base { Conditions { } Actions { Disable SetHitPoints "default 3" Idle "mintime 1.5" "maxtime 1.5" MessageWait "GOBLINATTACK" "1.0" SetDynamicTerrainMask "32" SetState "EnableCharacter" } } #--------------------------------------------- # Enables the character #--------------------------------------------- state EnableCharacter { Conditions { } Actions { DontPush SetNoOpponent NoRingSeg "false" Enable SetState "RunToTree" } } #--------------------------------------------- # Makes the character run to the tree #--------------------------------------------- state RunToTree { Conditions { if CanGetToLocator == 0.0 goto Patrol } Actions { GoToLocator "xz_rangecheck" MessageWait "GOBLINTREEFREE" "1" SetMessage "name GOBLINTREEFREE" "value 0" SetCreautreFlagOn "1" SetState "GoThroughGate" } } #--------------------------------------------- # Makes the character go through the flow gate #--------------------------------------------- state GoThroughGate { Conditions { if Timer > 0.4 goto BeckonColleaguesThroughGate } Actions { ResetTimer FollowPath } } #--------------------------------------------- # Enables the other characters to go through # the gate #--------------------------------------------- state BeckonColleaguesThroughGate { Conditions { } Actions { SetMessage "name GOBLINTREEFREE" "value 1" SetCreautreFlagOff "1" SetState "Patrol" } } #--------------------------------------------- # Follow the path nodes while looking for # an opponent to attack #--------------------------------------------- state Patrol { Conditions { if GotOpponent == 1 goto StartFight } Actions { FollowPath } } #--------------------------------------------- # Found an opponent, get the the main path #--------------------------------------------- state StartFight { Conditions { if GotOpponent == 0 goto Patrol } Actions { GoToLevelPath SetState "ApproachOpponent" } } #--------------------------------------------- # Walk towards the opponent before attacking #--------------------------------------------- state ApproachOpponent { Conditions { if GotOpponent == 0 goto Patrol if OpponentRange < 3.0 goto AttackOpp if OpponentRange > 5.0 goto FastApproachOpponent if Timer > 3.0 goto FastApproachOpponent } Actions { ResetTimer FollowOpponent "WALK" } } #-------------------------------------------- # Run towards the opponent before attacking #-------------------------------------------- state FastApproachOpponent { Conditions { if GotOpponent == 0 goto Patrol if OpponentRange < 3.0 goto AttackOpp if OpponentRange < 5.0 and if Timer < 3.0 goto ApproachOpponent } Actions { FollowOpponent "RUN" } } #-------------------------------------------- # Attack the opponent #-------------------------------------------- state AttackOpp { Conditions { if Random < 0.5 goto AttackOppNorm if PreviousResult > 0.0 goto AttackOppSpecial } Actions { } } state AttackOppNorm { Conditions { if Timer > 1.0 goto Think } Actions { ResetTimer EngageOpponent "goalrange 0.5" "firerange 3.5" "instant" } } state AttackOppSpecial { Conditions { } Actions { FaceOpponent SetActionValue "value 3" "waitcontextfree" WaitActionFinished SetState "Think" } } #-------------------------------------------- # Just attacked, decide what to do now #-------------------------------------------- state Think { Conditions { if GotOpponent == 0 goto Patrol if OpponentRange > 3.0 goto ApproachOpponent if OpponentRange < 1.2 goto AttackOpp if CircleClockwise "4096" == 1 goto CirclePlayerClockwise if CircleAntiClockwise "4096" == 1 goto CirclePlayerAntiClockwise if Random < 0.5 goto AttackOpp } Actions { FaceOpponent "1.0" } } #-------------------------------------------- # Circle around the player in a clockwise # direction #-------------------------------------------- state CirclePlayerClockwise { Conditions { if GotOpponent == 0 goto Patrol if OpponentRange > 3.0 goto ApproachOpponent if CircleClockwise "1024" == 0 goto Think } Actions { CircleOpponent "1.6" "walk" "facing" "CLOCKWISE" } } #-------------------------------------------- # Circle around the player in an # anticlockwise direction #-------------------------------------------- state CirclePlayerAntiClockwise { Conditions { if GotOpponent == 0 goto Patrol if OpponentRange > 3.0 goto ApproachOpponent if CircleAntiClockwise "1024" == 0 goto Think } Actions { CircleOpponent "1.6" "walk" "facing" "ANTICLOCKWISE" } } #-------------------------------------------- # If the character has just been hit by it's # opponent #-------------------------------------------- state TakenHit { Conditions { if GotOpponent == 0 goto AttackAttacker if OpponentRange > 3.0 goto ApproachOpponent } Actions { FaceOpponent "2.0" SetState "ApproachOpponent" } } #--------------------------------------------- # Enters this state when the character # has died #--------------------------------------------- state Killed { Conditions { if CheckCreatureFlag "1" == 1.0 goto ResetGoblinTreeFlag } Actions { ClearInterrupt "state ResetRingSeg" SetNoOpponent NoRingSeg "false" } } #--------------------------------------------- # Resets the message flag if this character # died during moving to the tree #--------------------------------------------- state ResetGoblinTreeFlag { Conditions { } Actions { ClearInterrupt "state ResetRingSeg" SetNoOpponent NoRingSeg "false" # Enable all other dwarfs since this one has died SetMessage "name GOBLINTREEFREE" "value 1" } } #--------------------------------------------- # Sets the character to attack the character # who attacked it #--------------------------------------------- state AttackAttacker { Conditions { } Actions { SetInterrupt "priority 0" "id 0" "state ResetRingSeg" "time 7.0" SetNoOpponent NoRingSeg GetAttackerAsOpponent FaceOpponent "1.0" SetState "ApproachOpponent" } } #--------------------------------------------- # Interupt handler to reset the ring segment #--------------------------------------------- state ResetRingSeg { Conditions { } Actions { SetNoOpponent NoRingSeg "false" SetState "Patrol" } }