{
	code: "bowtorn",
	class: "EntityAgent",
	tags: ["rust-creature", "habitat-land"],
	variantgroups: [
		{ code: "type", states: ["surface", "deep", "tainted", "corrupt", "nightmare", "gearfoot"]}
	],
	weight: 110,
	canClimb: true,
	hitboxSize: { x: 0.7, y: 2.3 },
	deadHitboxSize: { x: 1.3, y: 0.9 },
	eyeHeight: 1.8,
	attributes: {
		allowInDevastationArea: true,
		killedByInfoText: "deadcreature-vile",
		glitchAffected: true,
		glitchFlicker: true,
		reckless: true,
		extraSplashParticlesMul: 4,
		spawnCloserDuringLowStability: true,
		onDeathStabilityRecoveryByType: {
			"bowtorn-surface": 0.01,
			"bowtorn-deep": 0.015,
			"bowtorn-tainted": 0.02,
			"bowtorn-corrupt": 0.025,
			"bowtorn-nightmare": 0.3,
			"bowtorn-gearfoot": 0.35,
		}
	},
	drops: [],
	client: {
		renderer: "Shape",
		pitchStep: false,
		shapeByType: {
			"*-surface": { base: "entity/lore/bowtorn/surface" },
			"*-deep": { base: "entity/lore/bowtorn/deep" },
			"*-tainted": { base: "entity/lore/bowtorn/tainted" },
			"*-corrupt": { base: "entity/lore/bowtorn/corrupt" },
			"*-nightmare": { base: "entity/lore/bowtorn/nightmare" },
			"*-gearfoot": { base: "entity/lore/bowtorn/gearfoot" },
		},
		texturesByType: {
			"*-surface": {
				"skin": { base: "entity/lore/bowtorn/surface1", alternates: [ { base: "entity/lore/bowtorn/surface2" }, {base: "entity/lore/bowtorn/surface3" }, {base: "entity/lore/bowtorn/surface4" }] },
			},
			"*-deep": {
				"skin": { base: "entity/lore/bowtorn/deep1", alternates: [ { base: "entity/lore/bowtorn/deep2" } ] },
			},
			"*-tainted": {
				"skin": { base: "entity/lore/bowtorn/tainted1", alternates: [ { base: "entity/lore/bowtorn/tainted2" } ] },
			},
			"*-corrupt": {
				"skin": { base: "entity/lore/bowtorn/corrupt1", alternates: [ { base: "entity/lore/bowtorn/corrupt2" } ] },
			},
			"*-nightmare": {
				"skin": { base: "entity/lore/bowtorn/nightmare1", alternates: [ { base: "entity/lore/bowtorn/nightmare2" } ] },
			},
			"*-gearfoot": {
				"skin": { base: "entity/lore/bowtorn/gearfoot" },
			}
		},
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeight: 1.1251 }, 
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ code: "interpolateposition" },
			{ code: "harvestable", duration: 2 }
		],
		animations: [
			{
				code: "hurt",
				animation: "hurt", 
				animationSpeed: 2,
				weight: 10,
				blendMode: "AddAverage" 
			},
			{
				code: "die",
				animation: "die", 
				animationSpeed: 1,
				weight: 10,
				blendMode: "Average",
				triggeredBy: { onControls: ["dead"] }
			},
			{ 
				code: "idle",
				animation: "idle",
				blendMode: "Average", 
				triggeredBy: { defaultAnim: true },
			},
			{ 
				code: "walk", 
				animation: "walk",
				blendMode: "Average"
			},
			{ 
				code: "run", 
				animation: "run",
				blendMode: "Average"
			},
			{
				code: "turret",
				animation: "turret",
				blendMode: "Average"
			},
			{
				code: "load",
				animation: "load",
				blendMode: "Average"
			},
			{
				code: "hold",
				animation: "hold",
				blendMode: "Average"
			},
			{
				code: "unload",
				animation: "unload",
				blendMode: "Average"
			},
			{
				code: "reload",
				animation: "reload",
				blendMode: "Average"
			},
			{ 
				code: "stab", 
				animation: "stab",
				blendMode: "Average"
			}
		]
	},
	server: {
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeight: 1.1251 },
			{ code: "health", 
				currenthealthByType: {
					"*-surface": 10,
					"*-deep": 13,
					"*-tainted": 18,
					"*-corrupt": 25,
					"*-nightmare": 32,
					"*-gearfoot": 50
				},
				maxhealthByType: {
					"*-surface": 10,
					"*-deep": 13,
					"*-tainted": 18,
					"*-corrupt": 25,
					"*-nightmare": 32,
					"*-gearfoot": 50
				}
			},
			{ code: "deaddecay", hoursToDecay: 3 },
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ code: "despawn", minPlayerDistance: 32, minSeconds: 30 },
			{ code: "despawn", minPlayerDistance: 64, minSeconds: 6 },
			{
				code: "emotionstates",
				states: [  {
						code: "fleeondamage", 
						duration: 10,
						whenHealthRelBelow: 0.3,
						slot: 0, 
						priority: 1, 
						accumType: "max" 
					},
					{ code: "aggressiveondamage", duration: 30, chance: 1, slot: 0, priority: 0.5, accumType: "noaccum" },
				]
			},
			{
				code: "taskai",
				aitasks: [
					{
						code: "meleeattack",
						entityCodes: ["player"],
						priority: 4,
						damageByType: {
							"*-surface": 1.5,
							"*-deep": 2.5,
							"*-tainted": 5,
							"*-corrupt": 7,
							"*-nightmare": 12,
							"*-gearfoot": 14
						},
						damageTierByType: {
							"*-surface": 0,
							"*-deep": 1,
							"*-tainted": 2,
							"*-corrupt": 3,
							"*-nightmare": 4,
							"*-gearfoot": 4
						},
						damageTypeByType: {
							"*-corrupt": "SlashingAttack",
							"*-nightmare": "SlashingAttack",
							"*-gearfoot": "SlashingAttack"
						},
						mincooldown: 500, 
						maxcooldown: 1750, 
						damagePlayerAtMs: 400,
						attackDurationMs: 1000,
						animation: "stab",
						animationSpeed: 1.5,
						sound: "creature/drifter-hit",
						soundStartMs: 400
					},
					{
						code: "fleeentity",
						id: "intelliflee",
						entityCodes: ["player"],
						priority: 3,
						movespeed: 0.03,
						seekingRange: 9,
						fleeingDistance: 22,
						cancelOnHurt: true,
						intelligentFlee: true,
						animation: "run",
						animationSpeed: 1
					},
					{
						code: "fleeentity",
						entityCodes: ["player"],
						priority: 3,
						movespeed: 0.03,
						seekingRange: 35,
						cancelOnHurt: true,
						animation: "run",
						intelligentFlee: true,
						animationSpeed: 1,
						whenInEmotionState: "fleeondamage"
					},
					{
						code: "getoutofwater",
						priority: 2.5,
						movespeed: 0.015,
						animation: "swim",
						animationSpeed: 1.55
					},
					{
						code: "stayinrange",
						entityCodes: ["player"],
						priority: 2,
						searchRange: 30,
						targetRange: 20,
						targetRangeTolerance: 5,
						minDayLightByType: {
							"*-surface": 0.925,
							"*-deep": 0.97,
							"*-tainted": 2,
							"*-corrupt": 2,
							"*-nightmare": 2,
							"*-gearfoot": 2,
						},
						ignoreDeepDayLight: true,
						cancelOnHurt: true,
						executionChance: 0.05,
						movespeed: 0.0375,
						animation: "walk",
						animationSpeed: 2.8
					},
					{
						code: "turretmode",
						priority: 1.5,
						priorityForCancel: 3.5,
						sensingRange: 30,
						firingRangeMin: 14,
						firingRangeMax: 29,
						abortRange: 14,
						projectileDamageByType: {
							"*-surface": 5,
							"*-deep": 6,
							"*-tainted": 7,
							"*-corrupt": 8,
							"*-nightmare": 9,
							"*-gearfoot": 10,
						},
						projectileDamageTierByType: {
							"*-surface": 0,
							"*-deep": 0,
							"*-tainted": 0,
							"*-corrupt": 0,
							"*-nightmare": 0,
							"*-gearfoot": 0,
						},
						projectileCode: "bowtornprojectile"
					},
					{
						code: "idle",
						priority: 1.25,
						priorityForCancel: 1.35,
						minduration: 8000,
						maxduration: 8000,
						mincooldown: 60000,
						maxcooldown: 180000,
						animation: "Contort",
						animationSpeed: 1
					},
					{
						code: "wander", 
						priority: 1.0, 
						movespeed: 0.012,
						animation: "walk",
						animationSpeed: 1.5,
						preferredLightLevel: 15
					},
					{ 
						code: "lookaround", 
						priority: 0.5
					}
				]
			},
			{ code: "harvestable", duration: 2, fixedweight: true, dropsByType: {
				"*-surface": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 0.02666, var: 0 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 0.2, var: 0 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 0.01, var: 0 }
					},
					{
						type: "item",
						code: "arrow-bone",
						quantity: { avg: 0.8, var: 0 }
					}
				],
				"*-deep": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 0.033325, var: 0 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 0.03, var: 0 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 0.4, var: 0 }
					},
					{
						type: "item",
						code: "arrow-bone",
						quantity: { avg: 1, var: 0 }
					}
				],		
				"*-tainted": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 0.03999, var: 0 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 0.07, var: 0 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 0.6, var: 0 }
					},
					{
						type: "item",
						code: "arrow-bone",
						quantity: { avg: 1.5, var: 0 }
					}
				],
				"*-corrupt": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 0.046655, var: 0 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 0.1, var: 0 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 0.8, var: 0 }
					},
					{
						type: "item",
						code: "arrow-bone",
						quantity: { avg: 2, var: 0 }
					}
				],
				"*-nightmare": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 0.05332, var: 0 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 0.2, var: 0 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 1, var: 0 }
					},
					{
						type: "item",
						code: "arrow-bone",
						quantity: { avg: 3, var: 0 }
					}
				],
				"*-gearfoot": [
					{
						type: "item",
						code: "gear-temporal",
						quantity: { avg: 1, var: 0.4 }
					},
					{
						type: "item",
						code: "gear-rusty",
						dropModbyStat: "rustyGearDropRate",
						quantity: { avg: 5, var: 2.5 }
					},
					{
						type: "item",
						code: "flaxfibers",
						quantity: { avg: 2, var: 0 }
					},
					{
						type: "item",
						code: "stackrandomizer-alljonas",
						quantity: { avg: 0.4, var: 0 }
					}
				],
				},
			},
			{ code: "ripharvestable" },
			{ code: "entitystatetags" }
		],
		spawnconditions: {
			runtime: {
				group: "hostile",
				maxQuantityByType: {
					"*-surface": 1,
					"*-deep": 1,
					"*-tainted": 1,
					"*-corrupt": 1,
					"*-nightmare": 1,
					"*-gearfoot": 0
				},
				maxLightLevel: 7,
				chance: 0.1,
				lightLevelType: "OnlyBlockLight",
				groupSizeByType: {
					"*-surface": { dist: "invexp", avg: 1, var: 3 },
					"*": { dist: "uniform", avg: 1.5, var: 0.5 },
				},
				insideBlockCodes: ["air", "tallgrass-*", "loosestones-*"],
				minYByType: {
					"*-surface": 0.85,
					"*-deep": 0.22,
					"*-tainted": 0.1,
					"*-corrupt": 0,
					"*-nightmare": 0
				},
				maxYByType: {
					"*-surface": 2,
					"*-deep": 0.89,
					"*-tainted": 0.55,
					"*-corrupt": 0.35,
					"*-nightmare": 0.23
				}
			}
		}
	},
	sounds: {
		hurt: "creature/bowtorn/hurt",
		death: "creature/bowtorn/death",
		idle: { path: "creature/bowtorn/idle", range: 14, pitch: { avg: 1, var: 0.25 } }
	}
}
