{
	code: "bear",
	class: "EntityAgent",
	tags: ["animal", "huntable", "adult", "predator", "ferocious", "habitat-land"],
	weightByType: {
		"bear-black-*": 252,
		"bear-brown-*": 505,
		"bear-sun-*": 57,
		"bear-panda-*": 105,
		"bear-polar-*": 705
	},
	variantgroups: [
		{ code: "type", states: ["black", "brown", "sun", "panda", "polar"]},
		{ code: "age", states: ["adult"] },
		{ code: "gender", states: ["male", "female"] },
	],
	canClimbByType: {
		"bear-polar-*": false,
		"*": true
	},
	collisionBoxSizeByType: {
		"*-polar-adult-male": { x: 1.6, y: 1.3 },
		"*-polar-adult-female": { x: 1.4, y: 1.2 },
		
		"*-sun-adult-male": { x: 1.15, y: 1.1 },
		"*-sun-adult-female": { x: 1.0, y: 0.9 },
		
		"*-male": { x: 1.3, y: 1.2 },
		"*-female": { x: 1.25, y: 1.1 }
	},
	deadCollisionBoxSizeByType: {
		"*-polar-adult-male": { x: 1.2, y: 0.75},
		"*-polar-adult-female": { x: 1.1, y: 0.7 },
		
		"*-sun-adult-male": { x: 0.7, y: 0.5 },
		"*-sun-adult-female": { x: 0.7, y: 0.5 },
		
		"*-male": { x: 1, y: 0.7 },
		"*-female": { x: 0.9, y: 0.7 }
	},	
	selectionBoxSizeByType: {
		"bear-black-*": { x: 1.5, y: 1.8 },
		"bear-brown-*": { x: 1.5, y: 1.8 },
		"bear-sun-*": { x: 1.2, y: 1.2 },
		"bear-panda-*": { x: 1.5, y: 1.8 },
		"bear-polar-*": { x: 2.1, y: 2.9 }
	},
	deadSelectionBoxSizeByType: {
		"bear-black-*": { x: 1.2, y: 1.0 },
		"bear-brown-*": { x: 1.2, y: 1.0 },
		"bear-sun-*": { x: 1.1, y: 1.0 },
		"bear-panda-*": { x: 1.2, y: 1.0 },
		"bear-polar-*": { x: 1.7, y: 1.5 },
	},	
	knockbackResistanceByType: {
		"bear-black-*": 0.5,
		"bear-brown-*": 0.9,
		"bear-sun-*": 0.5,
		"bear-panda-*": 0.5,
		"bear-polar-*": 1
	},
	eyeHeight: 0.95,
	swimmingEyeHeight: 1.1,
	drops: [],
	attributes: {
		killedByInfoText: "deadcreature-eaten-large",
		handbook: {
			groupcode: "creaturegroup-bear-{type}",
			trappableGroupCode: "creaturegroup-bear-{type}-{age}"
		},
		creatureDietByType: {
			"bear-panda-*": {
				weightedFoodTags: [
					{ weight: 1, code: "tastyvegetable" }
				]
			},
			"bear-sun-*": {
				foodCategories: ["Fruit"],
				weightedFoodTags: [
					{ weight: 1, code: "fruit" },
					{ weight: 1, code: "lootableSweet" },
					{ weight: 1, code: "sweetBerryBush" }
				]
			},
			"*": {
				weightedFoodTags: [
					{ weight: 1, code: "meat" }
				]			
			}
		},
		trappable: {
			"small": { trapChance: 0, trapDestroyChance: 0.95 },
			"large": { trapChance: 0, trapDestroyChance: 0.5 }
		}
	},
	client: {
		renderer: "Shape",
		shape: { base: "entity/animal/mammal/bear/{type}-{age}" },
		texture: { base: "entity/animal/mammal/bear/{type}-{age}*" },
		sizeByType: {
			"*-female": 0.95,
			"*-male": 1.05
		},
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeightByType: 
			{
				"bear-polar-*": 2.8751,
				"bear-sun-*": 2.1251,
				"*": 3.1251
			}
			}, 
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ code: "interpolateposition" },
			{ code: "harvestable" },
			{ code: "despawn", minPlayerDistance: 16, belowLightLevel: 8, minSeconds: 300, afterDays: 14 },
		],
		animations: [
			{
				code: "hurt",
				animation: "hurt", 
				animationSpeed: 2.2,
				weight: 10,
				blendMode: "AddAverage" 
			},
			{
				code: "die",
				animation: "die", 
				animationSpeed: 1.25,
				weight: 10,
				blendMode: "Average",
				triggeredBy: { onControls: ["dead"] }
			},
			{ 
				code: "idle", 
				animation: "idle",
				blendMode: "AddAverage",
				easeOutSpeed: 4,
				animationSpeedByType: {
					"bear-black-*": 0.6,
					"bear-brown-*": 0.6,
					"bear-sun-*": 0.8,
					"bear-panda-*": 0.5,
					"bear-polar-*": 0.4
				},
				triggeredBy: { defaultAnim: true },
			},
			{
				code: "sleep", 
				animation: "sleep",
				easeInSpeed: 4,
				easeOutSpeed: 4,
				weight: 1.25,
				blendMode: "Average", 
			},
			{
				code: "sit", 
				animation: "sit",
				easeInSpeed: 4,
				easeOutSpeed: 3,
				animationSpeedByType: {
					"bear-black-*": 0.6,
					"bear-brown-*": 0.6,
					"bear-sun-*": 0.8,
					"bear-panda-*": 0.5,
					"bear-polar-*": 0.4
				},
				supressDefaultAnimation: true,
				blendMode: "Average", 
			},
			{
				code: "stand",
				animation: "stand",
				easeOutSpeed: 2,
				weight: 1,
				blendMode: "Average", 
			},
			{
				code: "lie",
				animation: "lie",
				animationSpeedByType: {
					"bear-black-*": 0.3,
					"bear-brown-*": 0.3,
					"bear-sun-*": 0.4,
					"bear-panda-*": 0.25,
					"bear-polar-*": 0.2
				},
				blendMode: "Average", 
			},
			{
				code: "walk",
				animation: "walk",
				supressDefaultAnimation: true,
				blendMode: "AddAverage",
                animationSounds: [{frame: 4, range: 15, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame: 16, range: 15, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame: 19, range: 15, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame: 30, range: 15, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}],
            },
			{
            	code: "run",
				animation: "run",
                animationSounds: [{frame: 14, range: 25, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame: 15, range: 25, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame:22, range: 25, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}, {frame: 26, range: 25, location: "creature/bear/footsteps/dirt/bear-footstep-dirt*", pitch: { avg: 1.0, var: 0.15 }}],
			}
		]
	},
	server: {
		attributes: {
			pathfinder: {
				minTurnAnglePerSec: 350,
				maxTurnAnglePerSec: 650
			}
		},
		behaviors: [
			{ code: "repulseagents" }, 
			{ code: "controlledphysics", stepHeightByType: 
			{
				"bear-polar-*": 2.8751,
				"bear-sun-*": 2.1251,
				"*": 3.1251
			}
			}, 
			{ code: "despawn", minPlayerDistance: 16, belowLightLevel: 8, minSeconds: 300, afterDays: 21 },
			{ code: "health", 
				maxhealthByType: {
					"bear-black-*": 44,
					"bear-brown-*": 64,
					"bear-sun-*": 34,
					"bear-panda-*": 38,
					"bear-polar-*": 66
				}
			},
			{ code: "deaddecay", hoursToDecay: 96, decayedBlock: "carcass-large" },
			{ code: "floatupwhenstuck", onlyWhenDead: true },
			{ code: "harvestable", drops: [
				{
					type: "item", 
					code: "bushmeat-raw", 
					quantityByType: {
						"bear-black-*": { avg: 12, var: 2 },
						"bear-brown-*": { avg: 16, var: 2 },
						"bear-sun-*": { avg: 9, var: 2 },
						"bear-panda-*": { avg: 10, var: 2 },
						"bear-polar-*": { avg: 22, var: 2 },
					},
				},
				{
					type: "item", 
					code: "hide-raw-bear-{type}-complete", 
					quantity: { avg: 1, var: 0 },
				},
				{
					type: "item", 
					code: "fat", 
					quantityByType: {
						"bear-black-*": { avg: 2, var: 1 },
						"bear-brown-*": { avg: 3, var: 1 },
						"bear-sun-*": { avg: 1, var: 1 },
						"bear-panda-*": { avg: 2, var: 1 },
						"bear-polar-*": { avg: 4, var: 1 },
					},
				}
				]
			},
			{ code: "breathe" },
			{ 
				code: "emotionstates",
				states: [
					{ code: "fleeondamage", 
							duration: 30, 
							chanceByType: {
								"bear-black-*": 0.1,
								"bear-brown-*": 0.05,
								"bear-sun-*": 0.05,
								"bear-panda-*": 0.3,
								"bear-polar-*": 0.05
							}, 
							slot: 2, 
							priority: 5, 
							accumType: "max", 
							whenHealthRelBelow: 0.3 
					},
					{ 
						code: "saturated", 
						duration: 1200, chance: 1, slot: 0, priority: 1, accumType: "sum",
						belowTempDuration: 600,
						belowTempThreshold: -5
					},
					{ code: "aggressiveondamage", duration: 30, chance: 1, slot: 2, priority: 2, accumType: "noaccum" },
					{ code: "alarmherdondamage", chance: 1, slot: 1, priority: 1, accumType: "max" },
				],
			},
			{ 
				code: "taskai",
				aiCreatureType: "LandCreature",
				aitasks: [
					{
						code: "meleeattack",
						priority: 2,
						entityCodes: ["player"],
						damageTier: 2,
						damageByType: {
							"bear-black-*": 10,
							"bear-brown-*": 12,
							"bear-sun-*": 4,
							"bear-panda-*": 8,
							"bear-polar-*": 16
						},
						damageType: "SlashingAttack",
						damage: 15,
						minDist: 2.5,
						minVerDist: 1.5,
						slot: 1,
						mincooldown: 1500, 
						maxcooldown: 1500, 
						attackDurationMs: 800,
						damagePlayerAtMs: 500,
						animation: "Attack",
						animationSpeed: 1,
						sound: "creature/bear/attack",
						whenInEmotionState: "aggressiveondamage"
					},
					{
						code: "fleeentity",
						priority: 1.7,
						entityCodes: ["player"],
						seekingRange: 20,
						animation: "Run",
						sound: "creature/bear/flee",
						whenInEmotionState: "fleeondamage",
						// Move and anim speeds tuned to male versions only
						animationSpeedByType: {
							"bear-sun-*": 2.3,
							"bear-panda-*": 1.9,
							"bear-polar-*": 1.8,
							"bear-brown-*": 2,
							"bear-black-*": 2
						},
						movespeedByType: {
							"bear-sun-*": 0.025,
							"bear-panda-*": 0.025,
							"bear-black-*": 0.04,
							"bear-brown-*": 0.055,
							"bear-polar-*": 0.06
						}
					},
					{
						code: "meleeattack",
						priority: 1.65,
						entityCodes: ["player", "chicken-*", "hare-*", "fox-*", "raccoon-*", "pig-*", "sheep-*", "deer-*", "goat-*"],
						damageByType: {
							"bear-black-*": 10,
							"bear-brown-*": 12,
							"bear-sun-*": 4,
							"bear-panda-*": 8,
							"bear-polar-*": 16
						},
						damageTier: 2,
						damageType: "SlashingAttack",
						damage: 15,
						minDistByType: {
							"bear-brown-*": 4,
							"bear-polar-*": 4,
							"*": 3
						},
						minVerDist: 1.5,
						slot: 1,
						mincooldown: 1500, 
						maxcooldown: 1500, 
						attackDurationMs: 800,
						damagePlayerAtMs: 500,
						animation: "Attack",
						animationSpeed: 1,
						sound: "creature/bear/attack"
					},					
					{
						code: "seekentity",
						priority: 1.6,
						// Empty entity codes list means it will not actively seek creatures, but will still execute retaliatory attacks
						entityCodesByType: {
							"bear-panda-*": [],
							"bear-sun-*": [],
							"*": ["player", "chicken-*", "hare-*", "fox-*", "raccoon-*", "pig-*", "sheep-*", "deer-*", "goat-*"]
						},
						skipEntityCodesByType: {
							"bear-brown-*": ["chicken-baby", "hare-*-baby-*"],
							"bear-polar-*": ["chicken-baby", "hare-*-baby-*"]
						},
						extraTargetDistance: 0.5,
						seekingRange: 20,
						belowTempSeekingRange: 25,
						belowTempThreshold: -10,
						animation: "Run",
						sound: "creature/bear/aggro",
						whenNotInEmotionState: "saturated",
						animationSpeedByType: {
							"bear-sun-*": 2.3,
							"bear-panda-*": 1.9,
							"bear-polar-*": 1.8,
							"bear-brown-*": 2,
							"bear-black-*": 2
						},
						movespeedByType: {
							"bear-sun-*": 0.025,
							"bear-panda-*": 0.025,
							"bear-black-*": 0.04,
							"bear-brown-*": 0.055,
							"bear-polar-*": 0.06
						}
					},
					{
						code: "fleeentity",
						priority: 1.5,
						entityCodes: ["player"],
						enabledByType: {
							"bear-panda-*": true,
							"bear-sun-*": true,
							"*": false
						},
						seekingRange: 5,
						animation: "Run",
						animationSpeedByType: {
							"bear-sun-*": 2.3,
							"bear-panda-*": 1.9
						},
						movespeedByType: {
							"bear-sun-*": 0.025,
							"bear-panda-*": 0.025
						}
					},					
					{
						code: "seekentity",
						entityCodes: ["player"],
						priority: 1.45,
						seekingRange: 30,
						animation: "Run",
						leapAtTarget: true,
						leapAnimation: null,
						leapChance: 0.01,
						sound: "creature/bear/aggro",
						whenInEmotionState: "aggressiveondamage",
						animationSpeedByType: {
							"bear-sun-*": 2.3,
							"bear-panda-*": 1.9,
							"bear-polar-*": 1.8,
							"bear-brown-*": 2,
							"bear-black-*": 2
						},
						movespeedByType: {
							"bear-sun-*": 0.025,
							"bear-panda-*": 0.025,
							"bear-black-*": 0.04,
							"bear-brown-*": 0.055,
							"bear-polar-*": 0.06
						}
					},
					{
						code: "getoutofwater",
						priority: 1.4,
						movespeedByType: {
							"bear-polar-*": 0.035,
							"*": 0.015
						},
						animation: "Swim",
						animationSpeedByType: {
							"bear-polar-*": 0.8,
							"*": 1
						}
					},
					{
						code: "idle",
						priority: 1.3,
						priorityForCancel: 1.35,
						minduration: 200000,
						maxduration: 800000,
						mincooldown: 10000,
						maxcooldown: 30000,
						animation: "Sleep",
						animationSpeed: 0.3,
						whenNotInEmotionState: "aggressiveondamage",
						duringDayTimeFrames: [ { fromHour: 10, toHour: 18 }, { fromHour: 1, toHour: 3 } ],
						stopOnNearbyEntityCodes: ["player"],
						stopRange: 10,
						stopOnHurt: true
					},					
					{
						code: "idle",
						priority: 1.2,
						priorityForCancel: 1.35,
						minduration: 4667,
						maxduration: 4667,
						mincooldown: 80000,
						maxcooldown: 500000,
						animation: "Stand",
						whenNotInEmotionState: "aggressiveondamage",
						animationSpeed: 0.5
					},
					{
						code: "idle",
						priority: 1.1,
						priorityForCancel: 1.35,
						minduration: 2500,
						maxduration: 2500,
						mincooldown: 6000,
						maxcooldown: 20000,
						animation: "Stand",
						whenNotInEmotionState: "aggressiveondamage",
						animationSpeed: 1.25
					},
					{
						code: "wander", 
						priority: 1.0, 
						priorityForCancel: 1.35,
						animation: "Walk",
						preferredLightLevel: 20,
						animationSpeedByType: {
							"bear-sun-*": 1.1,
							"bear-black-*": 0.9,
							"bear-brown-*": 1.15,
							"bear-panda-*": 1,
							"bear-polar-*": 0.9,
						},
						movespeedByType: {
							"bear-sun-*": 0.01,
							"bear-black-*": 0.013,
							"bear-polar-*": 0.017,
							"bear-brown-*": 0.015,
							"bear-panda-*": 0.011,
						},
					},
					{
						code: "idle",
						priority: 0.9,
						priorityForCancel: 1.35,
						minduration: 5000,
						maxduration: 30000,
						mincooldown: 2000,
						maxcooldown: 120000,
						animation: "Sit",
						supressDefaultAnimation: true,
						whenNotInEmotionState: "aggressiveondamage",
						stopOnNearbyEntityCodes: ["player"],
						stopRange: 5
					},
					{
						code: "idle",
						priority: 0.6,
						priorityForCancel: 1.35,
						minduration: 5000,
						maxduration: 30000,
						mincooldown: 2000,
						maxcooldown: 120000,
						animation: "Lie",
						whenNotInEmotionState: "aggressiveondamage",
						stopOnNearbyEntityCodes: ["player"],
						stopRange: 5
					},
					{ 
						code: "lookaround", 
						turnSpeedMul: 0.2,
						priority: 0.5
					}
				]
			},
			{ code: "entitystatetags" }
		],
		spawnconditions: {
			worldgen: {
				TriesPerChunk: { avg: 0.007, var: 0 },
				tryOnlySurface: true,
				groupSize: { dist: "verynarrowgaussian", avg: 1, var: 1 },
				insideBlockCodesByType: {
					"bear-panda-*": ["air", "tallgrass-*", "snowlayer-*", "flower-*", "leaves-*", "bambooleaves-*", "tallfern", "fern-*" ],
					"bear-*": ["air", "tallgrass-*", "snowlayer-*", "flower-*"],
				}
			},
			runtime: {
				group: "hostile",
				MinDistanceToPlayer: 30,
				tryOnlySurface: true,
				chance: 0.000015,
				maxQuantity: 1,
				maxQuantityByGroup: { code: "bear-*", "maxQuantity": 4 },
				groupSize: { dist: "verynarrowgaussian", avg: 1, var: 1 },
				insideBlockCodesByType: {
					"bear-panda-*": ["air", "tallgrass-*", "snowlayer-*", "flower-*", "leaves-*", "bambooleaves-*", "tallfern", "fern-*" ],
					"bear-*": ["air", "tallgrass-*", "snowlayer-*", "flower-*"],
				},
				// Make them spawn away from artifical light so they don't spawn inside farmland
				maxLightLevel: 7,
				lightLevelType: "onlyBlockLight"			
			},
			climate: {
				maxY: 1.6,
				minTempByType: {
					"bear-polar-*": -48,
					"bear-brown-*": -15,
					"bear-sun-*": 24,
					"bear-panda-*": 25,
					"bear-black-*": -5
				},
				maxTempByType: {
					"bear-polar-*": -9,
					"bear-brown-*": 10,
					"bear-sun-*": 40,
					"bear-panda-*": 33,
					"bear-black-*": 20
				},
				minRainByType: {
					"bear-polar-*": 0,
					"bear-brown-*": 0.1,
					"bear-sun-*": 0.6,
					"bear-panda-*": 0.5,
					"*": 0.25
				},
				minForestByType: {
					"bear-polar-*": 0,
					"bear-brown-*": 0.2,
					"bear-black-*": 0.5,
					"bear-panda-*": 0.5,
					"bear-sun-*": 0.4,
					"*": 0.4
				}
			}
		}
	},
	sounds: {
		hurt: "creature/bear/hurt",
		death: "creature/bear/flee",
		idle: { path: "creature/bear/growl*", pitch: { avg: 1, var: 0.25 } }
	},
	idleSoundChance: 0.1
}
