[
	// This is not really a state but rather a collection of steps
	// that are done regardless of the current state
	{
		name: "signalBadIntentions",
		steps: [
			{
				name: "modifyComponent",
				params: {
					component: "EyewitnessComponent",
					values: {
						flashSmallWitnessIcon: true,
					}
				}
			},
			{
				name: "offscreenAlert",
				params: {
					baseDefinition: "alertBaseNegative",
					iconDefinition: "alertIconEye",
				}
			},
		],
		doNotOptimize: true
	},

	{
		name: "callPoliceOnPublicPhone",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					category: "phone",
					group: "public",
					hasToBeEmpty: true,
				}
			},
			{
				name: "almostAtHotspot",
				params: {
					distance: 3,
					state: "signalBadIntentions",
				}
			},

			{
				name: "specialAction",
				params: {
					name: "call"
				}
			},
			{
				name:"spawnSpeak",
				params: {
					definitions: [
						"reactionCallPolice1",
						"reactionCallPolice2",
						"reactionCallPolice3",
						"reactionCallPolice4",
					],
				}
			},
			{
				name: "setFlag",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "modifyComponent",
				params: {
					component: "EyewitnessComponent",
					values: {
						flashSmallWitnessIcon: false,
					}
				}
			},
		]
	},

	{
		name: "callPoliceOnAnyPhone",
		cooldown: 5,
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "callPolice"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "policeCalled",
					global: true,
				}
			},/*
			{
				name: "distanceToTargetMoreThan",
				params: {
					distance: 5,
				}
			},*/
			{
				name: "canGotoHotspot",
				params: {
					category: "phone",
					hasToBeEmpty: true,
				}
			}
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					category: "phone",
					hasToBeEmpty: true,
				}
			},
			{
				name: "almostAtHotspot",
				params: {
					distance: 3,
					state: "signalBadIntentions",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "call"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definition: "reactionCopsShouldBeArrivingShortly",
				}
			},
			{
				name: "modifyComponent",
				params: {
					component: "EyewitnessComponent",
					values: {
						flashSmallWitnessIcon: false,
					}
				}
			},
		]
	},

	{
		name: "guardCallPolice",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "or",
				params: [
					{
						name: "flagSet",
						params: {
							name: "intimidated",
						}
					},
					{
						name: "flagSet",
						params: {
							name: "aggressive",
						}
					},
					{
						name: "flagSet",
						params: {
							name: "panic",
						}
					},
					{
						name: "flagSet",
						params: {
							name: "callPolice",
						}
					},
				]
			},
			{
				name: "canGotoHotspot",
				params: {
					category: "phone",
					hasToBeEmpty: true,
				}
			},
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "phone",
					hasToBeEmpty: true,
				}
			},
			{
				name: "almostAtHotspot",
				params: {
					distance: 3,
					state: "signalBadIntentions",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "call"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definition: "reactionCopsShouldBeArrivingShortly",
				}
			},
			{
				name: "modifyComponent",
				params: {
					component: "EyewitnessComponent",
					values: {
						flashSmallWitnessIcon: false,
					}
				}
			},
			{
				name: "setFlag",
				params: {
					name: "aggressive",
				}
			},
		]
	},

	{
		name: "guardCannotCallPoliceBeHero",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "or",
				params: [
					{
						name: "flagSet",
						params: {
							name: "intimidated",
						}
					},
					{
						name: "flagSet",
						params: {
							name: "callPolice",
						}
					},
				]
			},
			{
				name: "canNotGotoHotspot",
				params: {
					category: "phone",
					hasToBeEmpty: true,
				}
			},
		],
		steps: [
			{
				name: "modifyComponent",
				params: {
					component: "EyewitnessComponent",
					values: {
						flashSmallWitnessIcon: false,
					}
				}
			},
			{
				name: "pickTargetFromVisible",
				params: {
					belongsToTeam: "goons"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "aggressive",
				}
			},
		]
	},

	{
		name: "exitInPanic",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic"
				}
			},
			{
				name: "atHotspot",
				params: {
					categories: ["mapExit"]
				}
			},
		],
		steps: [
			{
				name: "setFlag",
				params: {
					name: "policeCalled",
					global: true,
				}
			},
			{
				name: "removeEntity",
			}
		]
	},

	{
		name: "exitInPanicNoCops",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic"
				}
			},
			{
				name: "atHotspot",
				params: {
					categories: ["mapExit"]
				}
			},
		],
		steps: [
			{
				name: "removeEntity",
			}
		]
	},

	{
		name: "exitPeacefully",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "readyToLeave"
				}
			},
			{
				name: "atHotspot",
				params: {
					categories: ["mapExit"]
				}
			},
		],
		steps: [
			{
				name: "removeEntity",
			}
		]
	},


	{
		name: "lookAround",
		steps: [
			{
				name: "turnInPlace",
				params: {
					random: true
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAround"
				}
			}
		]
	},

	{
		name: "frozen",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "freeze",
				}
			}
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "frozen",
				}
			}
		]
	},

	{
		name: "equipGun",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "gunEquipped",
				}
			},
		],
		steps: [
			{
				name: "equipInventoryItem",
				params: {
					type: "weapon"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "gunEquipped",
				}
			},
		]
	},

	{
		name: "pickupGun",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "hasGun"
				}
			},
			{
				name: "flagSet",
				params: {
					name: "getGun"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run",
				}
			},
			{
				name: "gotoHotspot",
				params: {
					name: "gunPickup"
				}
			},
			{
				name: "pickup",
				params: {
					type: "weapon"
				}
			},
			{
				name: "equipInventoryItem",
				params: {
					type: "weapon"
				}
			},
			{
				name: "unsetFlag",
				params: {
					name: "getGun"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "hasGun"
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionGotGun1",
						"reactionGotGun2",
						"reactionGotGun3",
						"reactionGotGun4",
						"reactionGotGun5",
						"reactionGotGun6"
					],
				}
			},
			{
				name: "setFlag",
				params: {
					name: "aggressive"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "callPolice",
				}
			},
		]
	},

	{
		name: "fight",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
			{
				name: "canEngageTarget",
			},
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run",
				}
			},
			// Remember rememberTargetCoordinates
			{
				name: "rememberWaypoint",
				params: {
					name: "opponentPosition",
					useCurrentTargetEntitysPosition: true,
				}
			},
			{
				name: "followTarget",
				params: {
					closeEnoughDistance: 0.30,
					//maxDistance: 2.0
				}
			},
			{
				name: "useWeaponOnTarget"
			}
		]
	},

	{
		name: "gotoOpponentsLastLocation",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
			{
				name: "hasTarget",
			},
			{
				name: "canNotSeeTarget",
				params: {
					// Goto opponents location even if we see from cameras
					ignoreRelayed: true,
				}
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
		],
		steps: [
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionWhereDidYouGo1",
						"reactionWhereDidYouGo2",
						"reactionWhereDidYouGo3",
						"reactionWhereDidYouGo4",
					],
				}
			},
		]
	},

	{
		name: "zombieGotoOpponentsLastLocation",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
			{
				name: "hasTarget",
			},
			{
				name: "canNotSeeTarget",
				params: {
					// Goto opponents location even if we see from cameras
					ignoreRelayed: true,
				}
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
		],
		steps: [
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: ["reactionZombieLostTarget"],
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			{
				name: "specialAction",
				params: {
					name: "lookAround"
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			{
				name: "specialAction",
				params: {
					name: "lookAround"
				}
			},
		]
	},

	{
		name: "leavingInPanic",
		cooldown: 2,
		maxDuration: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run",
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionLeavePanic1",
						"reactionLeavePanic2",
						"reactionLeavePanic3",
						"reactionLeavePanic4"],
				}
			},
			{
				name: "gotoHotspot",
				params: {
					category: "mapExit"
				}
			},
			{
				name: "almostAtHotspot",
				params: {
					distance: 3,
					state: "signalBadIntentions",
				}
			},

		]
	},
	{
		name: "shoutInPanic",
		cooldown: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic",
				}
			},
			{
				name: "random",
				params: {
					probability: 0.7
				}
			},
		],
		steps: [
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionShoutPanic",
						"reactionShoutPanic2",
						"reactionShoutPanic3",
						"reactionShoutPanic4"],
				}
			},
		]
	},
	{
		name: "wanderAround",
		maxDuration: 2,
		cooldown: 6,
		conditions: [
		],
		steps: [
			{
				name: "wander"
			},
		]
	},
	{
		name: "runAroundInPanic",
		maxDuration: 4,
		cooldown: 4.5,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic",
				}
			},
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run",
				}
			},
			{
				name: "wander"
			},
		]
	},

	{
		name: "runningAroundInPanic",
		cooldown: 1,
		maxDuration: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic",
				}
			}
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run",
				}
			},
			{
				name: "gotoRandomWaypoint",
				params: {
					minX: -1000,
					minY: -1000,
					maxX: 1000,
					maxY: 1000
				}
			},
			{
				name: "maybeContinue",
				params: {
					probability: 0.5
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionLeavePanic1",
						"reactionLeavePanic2",
						"reactionLeavePanic3",
						"reactionLeavePanic4",
					],
				}
			},
		]
	},

	{
		name: "leavingWhenReady",
		cooldown: 1,
		maxDuration: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "readyToLeave",
				}
			}
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "mapExit"
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionLeaving1",
						"reactionLeaving2",
						"reactionLeaving3",
						"reactionLeaving4",
						"reactionLeaving5",
						"reactionLeaving6",
					],
				}
			},
		]
	},

	{
		name: "gotoJail",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "gotToJail",
				}
			}
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					// Just walk first so that we can open doors
					mode: "walk"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					// Go inside the doors
					name: "patrol1_3",
					hasToBeEmpty: false
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionJailCopHunt1",
						"reactionJailCopHunt2",
						"reactionJailCopHunt3",
						"reactionJailCopHunt4",
					],
				}
			},
			{
				name: "turnInPlace",
				params: {
					// THIS IS MADNESS, but if this is not here then
					// the next gotoHotspot fails :(
					angle: 90,
 				}
 			},
			{
				name: "setMovementMode",
				params: {
					// Now we are inside, start running
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					// Go to the spot inside the cell room, should see you at this point
					name: "patrol6_1",
					hasToBeEmpty: false
				}
			},
			{
				name: "setFlag",
				params: {
					// Set flag so that we don't do this again
					name: "gotToJail",
				}
			},
		]
	},
	{
		name: "seekAndDestroyJail",
		steps: [
			{
				name: "setMovementMode",
				params: {
					// Make sure we run!
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					// Just run around in the patrol route
					group: "patrol1",
					random: true
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionJailCopHunt1",
						"reactionJailCopHunt2",
						"reactionJailCopHunt3",
						"reactionJailCopHunt4",
					],
				}
			},
		]
	},

	{
		name: "bored",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "readyToLeave",
				}
			}
		],
		steps: [
			{
				name: "unsetFlag",
				params: {
					name: "oogled",
				}
			},
			// only maybe set "readyToLeave" flag to allow going back to oogling
			{
				name: "maybeContinue",
				params: {
					probability: 0.5
				}
			},
			{
				name: "setFlag",
				params: {
					name: "readyToLeave",
				}
			}
		]
	},

	{
		name: "atCashier",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "oogled"
				}
			},
			{
				name: "atHotspot",
				params: {
					names: ["queue1_1", "queue2_1", "queue4_1", "queue5_1"] // todo there should be a better way
				}
			}
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "atCashier"
				}
			},
			// Only set this after special action because if cashier
			// leaves in the middle of cashiering, we are not done
			{
				name: "setFlag",
				params: {
					name: "readyToLeave",
				}
			},
			{
				name: "maybeContinue",
				params: {
					probability: 0.5
				}
			},
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionPaying1",
						"reactionPaying2",
						"reactionPaying3",
						"reactionPaying4",
						"reactionPaying5",
						"reactionPaying6",
						"reactionPaying7",
					],
				}
			}
		],
	},

	{
		name: "queuing",
		maxDuration: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "oogled"
				}
			},
			{
				name: "canGotoHotspot",
				params: {
					category: "queue",
					behavior: "queue"
				}
			}
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "queue",
					behavior: "queue"
				}
			}
		]
	},

	{
		name: "waitingInQueue",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "oogled"
				}
			},
			{
				name: "atHotspot",
				params: {
					categories: ["queue"]
				}
			}
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "idleInQueue"
				}
			}
		]
	},

	{
		name: "idle",
		maxDuration: 2,
		steps: [
			{
				name: "specialAction",
				params: {
					name: "idle"
				}
			}
		]
	},

	{
		name: "oogling",
		maxDuration: 15,
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "oogled",
				}
			},
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "oogle",
					behavior: "random"
				}
			},
			{
				name: "specialAction",
				params: {
					name: "oogle"
				}
			},

			// only maybe set "oogled" flag to allow 1...N oogles before ready
			{
				name: "maybeContinue",
				params: {
					probability: 0.5
				}
			},
			{
				name: "setFlag",
				params: {
					name: "oogled"
				}
			},
		]
	},
	{
		name: "mousing",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "scared",
				}
			},
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "mouse",
					behavior: "random"
				}
			},
			{
				name: "specialAction",
				params: {
					name: "mouse"
				}
			},
			// only maybe set "oogled" flag to allow 1...N oogles before ready
		]
	},

	{
		name: "getGunTargetHasGun",
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "hasGun"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "getGun"
				}
			},
			{
				name: "targetHasEquipped",
				params: {
					type: "weapon"
				}
			},
		],
		steps: [
			{
				name: "spawnSpeak",
				params: {
					definitions: [
						"reactionGetGun1",
						"reactionGetGun2",
						"reactionGetGun3",
						"reactionGetGun4",
						"reactionGetGun5",
						"reactionGetGun6"
					],
				}
			},
			{
				name: "setFlag",
				params: {
					name: "getGun"
				}
			},
		]
	},

	{
		name: "investigateLooting",
		maxDuration: 10,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "investigateLooting",
				}
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "investigate",
				}
			},
		],
		steps: [
			// Goto remembered waypoint to get close enough
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "investigate"
				}
			},
			// Remember the point of looting, just in case
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "investigate"
				}
			},
			// Stop investigating
			{
				name: "unsetFlag",
				params: {
					name: "investigateLooting",
				}
			},
			// Look Around
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhileInvestigating"
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			// Finally go call the police
			{
				name: "setFlag",
				params: {
					name: "callPolice",
				}
			},
		]
	},

	{
		name: "investigate",
		conditions: [
			{
				// Maybe doesNotHaveTarget is better?
				name: "canNotSeeTarget",
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "investigate",
				}
			},
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhileInvestigating"
				}
			},
			// Look Around
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			// Goto remembered waypoint to get close enough
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "investigate"
				}
			},
			// Remember the point of looting, just in case
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "investigate"
				}
			},
			// Look Around
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
			{
				name: "superpawnEntityDefinition",
				params: {
					definitions: ["reactionWonder"],
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhileInvestigating"
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true,
 				}
 			},
		]
	},
	{
		name: "userCommands",
		steps: [],
		retainPlan: true,
	},
	{
		name: "goonAggressive",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},

			{
				name: "canSeeTarget",
				params: {
					ignoreRelayed: true
				}
			},
			{
				name: "targetWithinWeaponRange",
			},
		],
		steps: [
			{
				name: "rememberWaypoint",
				params: {
					name: "opponentPosition",
					useCurrentTargetEntitysPosition: true,
				}
			},
/*
			{
				name: "followTarget",
				params: {
					closeEnoughDistance: 0.30,
					//maxDistance: 2.0
				}
			},
*/
			{
				name: "useWeaponOnTarget"
			},
		]
	},

	{
		name: "goonGotoOpponentsLastLocation",
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "intimidated",
				}
			},
			{
				name: "hasTarget",
			},
			{
				name: "canNotSeeTarget",
				params: {
					// Goto opponents location even if we see from cameras
					ignoreRelayed: true,
				}
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
		],
		steps: [
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "opponentPosition",
				}
			},
		]
	},

	{
		name: "waitingForOrders",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "intimidated"
				}
			}
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "frozen"
				}
			},
		]
	},
/*					{
		name: "waitingForOrders",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
		],
		steps: [
			{
				name: "specialAction",
				params: {
					name: "waitingForOrdersAggressive"
				}
			},
		]
	},
*/	{
		name: "goonClearAggressive",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive"
				}
			},
		],
		steps: [
			{
				name: "unsetFlag",
				params: {
					name: "aggressive"
				}
			},
		]
	},

	{
		name: "goonWaitingForOrders",
		steps: [
			{
				name: "specialAction",
				params: {
					name: "waitingForOrders",
					// Make time very long so that we don't constantly try to pick
					// the same state again
					duration: 1000,
				}
			},
		]
	},
	{
		name: "poop",
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "shouldPoop",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "toilet",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "poop"
				}
			},
			{
				name: "unsetFlag",
				params: {
					name: "shouldPoop",
				}
			},
		]
	},

	{
		name: "shouldPoop",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "canPoop",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "shouldPoop",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "investigateLooting",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
						{
				name: "flagNotSet",
				params: {
					name: "panic",
				}
			},
			{
				name: "random",
				params: {
					probability: 0.2
				}
			},
		],
		steps: [
			{
				name: "unsetFlag",
				params: {
					name: "canPoop",
				}
			},
			{
				name: "setFlag",
				params: {
					name: "shouldPoop",
				}
			},
		]
	},

	{
		name: "getGoods",
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "shouldGetGoods",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
						{
				name: "flagNotSet",
				params: {
					name: "panic",
				}
			}
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "getGoods",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "getGoods"
				}
			},
			{
				name: "unsetFlag",
				params: {
					name: "shouldGetGoods",
				}
			},
		]
	},

	{
		name: "shouldGetGoods",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "canGetGoods",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "shouldGetGoods",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "investigateLooting",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "panic",
				}
			},
			{
				name: "random",
				params: {
					probability: 0.4
				}
			},
		],
		steps: [
			{
				name: "unsetFlag",
				params: {
					name: "canGetGoods",
				}
			},
			{
				name: "setFlag",
				params: {
					name: "shouldGetGoods",
				}
			},
		]
	},

	{
		name: "cashiering",
		maxDuration: 15,
		conditions: [
			{
				name: "flagNotSet",
				params: {
					name: "investigateLooting",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "aggressive",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "panic",
				}
			}
		],
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "cashier",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "atCashier"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "canGetGoods"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "canPoop",
				}
			},
		]
	},

	{
		name: "seekAndDestroy",
		cooldown: 2,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive",
				}
			},/*
			{
				name: "doesNotHaveTarget",
			},*/
		],
		steps: [
			{
				// If this finds a new target, it will trigger "gotTarget" and we
				// will abort this state and go straight to fight
				name: "pickTargetFromVisible",
				params: {
					belongsToTeam: "goons"
				}
			},
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoRandomWaypoint",
				params: {
					minX: -100,
					minY: -100,
					maxX: 100,
					maxY: 100
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhileInvestigating"
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true
				}
			},
		]
	},

	{
		name: "copSeekAndDestroy",
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "seekAndDestroy",
				}
			}
		],
		steps: [
			{
				name: "gotoRandomWaypoint",
				params: {
					minX: -100,
					minY: -100,
					maxX: 100,
					maxY: 100
				}
			},
		]
	},

	{
		name: "horseSeekAndDestroy",
		maxDuration: 15,
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive",
				}
			},
		],
		steps: [
			{
				// If this finds a new target, it will trigger "gotTarget" and we
				// will abort this state and go straight to fight
				name: "pickTargetFromVisible",
				params: {
					belongsToTeam: "goons"
				}
			},
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					behavior: "random"
				}
			},
		]
	},

	{
		name: "zombieSeek",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "aggressive",
				}
			},
		],
		steps: [
			{
				// If this finds a new target, it will trigger "gotTarget" and we
				// will abort this state and go straight to fight
				name: "pickTargetFromVisible",
				params: {
					belongsToTeam: "goons"
				}
			},
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoSomewhereClose",
			},
		],
		doNotOptimize: true,
	},

	{
		name: "rememberGuardPost",
		conditions: [
			{
				name: "doesNotHaveRememberedWaypoint",
				params: {
					name: "guardPost"
				}
			}
		],
		steps: [
			{
				name: "rememberWaypoint",
				params: {
					name: "guardPost",
				}
			},
		],
		doNotOptimize: true,
	},

	{
		name: "guarding",
		steps: [
			// A bit stupidly we first go to a close by waypoint,
			// then the actual guard coordinates
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "guardPost",
				}
			},
			{
				name: "gotoCoordinates",
				params: {
					name: "guardPost",
				}
			},
			{
				name: "turnInPlace",
				params: {
					random: true
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhilePatrolling"
				}
			}
		],
		doNotOptimize: true,
	},

	{
		name: "gotoLastPatrolHotspot",
		maxDuration: 20,
		conditions: [
			// Only go to this state if we are not at a patrol hotspot.
			// The idea is to only go to this state if we have wandered
			// somewhere from the route
			{
				name: "notAtHotspot",
				params: {
					categories: ["patrol"]
				}
			},
			{
				name: "hasRememberedWaypoint",
				params: {
					name: "lastPatrolHotspot",
				}
			},
		],
		steps: [
			{
				name: "gotoRememberedWaypoint",
				params: {
					name: "lastPatrolHotspot",
				}
			},
			{
				name: "clearRememberedWaypoint",
				params: {
					name: "lastPatrolHotspot",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhilePatrolling"
				}
			},
		]
	},

	{
		name: "patrolling",
		maxDuration: 20,
		cooldown: 2,
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "patrol",
					behavior: "patrol"
				}
			},
			// Every time you go to a patrol hotspot,
			// remember that hotspot. If the guard
			// goes investigating he can return to the
			// last patrol hotspot and continue patrolling
			// the correct route.
			{
				name: "rememberWaypoint",
				params: {
					name: "lastPatrolHotspot",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhilePatrolling"
				}
			},
		]
	},

	{
		name: "pingPongPatrolling",
		maxDuration: 20,
		cooldown: 2,
		steps: [
			{
				name: "gotoHotspot",
				params: {
					category: "patrol",
					behavior: "patrolBackAndForth"
				}
			},
			// Every time you go to a patrol hotspot,
			// remember that hotspot. If the guard
			// goes investigating he can return to the
			// last patrol hotspot and continue patrolling
			// the correct route.
			{
				name: "rememberWaypoint",
				params: {
					name: "lastPatrolHotspot",
				}
			},
			{
				name: "specialAction",
				params: {
					name: "lookAroundWhilePatrolling"
				}
			},
		]
	},

	{
		name: "demonSeekAndDestroy",
		steps: [
			{
				name: "gotoHotspot",
				params: {
					behavior: "random",
					hasToBeEmpty: false,
				}
			},
		]
	},

	{
		name: "demonIdle",
		steps: [
			{
				name: "specialAction",
				params: {
					name: "idle",
					// Make time very long so that we don't constantly try to pick
					// the same state again
					duration: 1000,
				}
			}
		]
	},

	{
		name: "zombieIdle",
		steps: [
			{
				name: "specialAction",
				params: {
					// Make time very long so that we don't constantly try to pick
					// the same state again
					name: "idle"
				}
			}
		]
	},


/*
	public static var inPanic:AIState = {
		name: "panic",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "panic",
				}
			}
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					category: "mapExit"
				}
			},
			{
				name: "removeEntity"
			}
		]
	};

	public static var inAlarm:AIState = {
		name: "alarm",
		conditions: [
			{
				name: "flagSet",
				params: {
					name: "alarm",
				}
			},
			{
				name: "flagNotSet",
				params: {
					name: "alarm",
					global: true,
				}
			}
		],
		steps: [
			{
				name: "setMovementMode",
				params: {
					mode: "run"
				}
			},
			{
				name: "gotoHotspot",
				params: {
					category: "alarm"
				}
			},
			{
				name: "specialAction",
				params: {
					name: "setAlarm"
				}
			},
			{
				name: "setFlag",
				params: {
					name: "alarm",
					global: true
				}
			},
		]
	}
*/
]

