{
  "id": "survival-override",
  "title": "Survival Override Enemy",
  "description": "A full enemy brain with a top-priority survival branch: when health runs low the agent abandons whatever it was doing to flee, heal, or fight cornered — no transitions required.",
  "root": "n1",
  "properties": {},
  "custom_nodes": [
    { "name": "IsHealthLow", "category": "condition", "title": "Is Health Low?", "description": "Succeeds if health is below the threshold.", "properties": { "threshold": 30 } },
    { "name": "FleeToCover", "category": "action", "title": "Flee To Cover", "description": "Runs to the nearest cover point away from the threat.", "properties": { "speed": 5 } },
    { "name": "UseHealthItem", "category": "action", "title": "Use Health Item", "description": "Consumes a health item if one is carried; fails otherwise.", "properties": {} },
    { "name": "FightCornered", "category": "action", "title": "Fight Cornered", "description": "Last resort: attacks desperately when there is no escape.", "properties": {} },
    { "name": "IsPlayerInRange", "category": "condition", "title": "Is Player In Range?", "description": "Succeeds if the player is within attack range.", "properties": { "range": 2 } },
    { "name": "AttackPlayer", "category": "action", "title": "Attack Player", "description": "Performs an attack against the player.", "properties": {} },
    { "name": "IsPlayerVisible", "category": "condition", "title": "Is Player Visible?", "description": "Succeeds if the player is within sight distance and line of sight.", "properties": { "distance": 10 } },
    { "name": "MoveToPlayer", "category": "action", "title": "Move To Player", "description": "Moves the agent toward the player's position.", "properties": { "speed": 4 } },
    { "name": "MoveToWaypoint", "category": "action", "title": "Move To Waypoint", "description": "Moves the agent toward the current patrol waypoint.", "properties": { "speed": 2 } },
    { "name": "NextWaypoint", "category": "action", "title": "Next Waypoint", "description": "Advances the patrol route to the next waypoint.", "properties": {} }
  ],
  "nodes": {
    "n1": { "id": "n1", "name": "Priority", "title": "Enemy AI", "description": "The survival branch is evaluated first on every tick, so it preempts everything below it.", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n2", "n7", "n10", "n13"] },
    "n2": { "id": "n2", "name": "Sequence", "title": "Survive", "description": "", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n3", "n4"] },
    "n3": { "id": "n3", "name": "IsHealthLow", "title": "Is Health Low?", "description": "", "properties": { "threshold": 30 }, "display": { "x": 0, "y": 0 } },
    "n4": { "id": "n4", "name": "Priority", "title": "Stay Alive", "description": "Escalating survival strategies, cheapest first.", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n5", "n6", "n6b"] },
    "n5": { "id": "n5", "name": "FleeToCover", "title": "Flee To Cover", "description": "", "properties": { "speed": 5 }, "display": { "x": 0, "y": 0 } },
    "n6": { "id": "n6", "name": "UseHealthItem", "title": "Use Health Item", "description": "", "properties": {}, "display": { "x": 0, "y": 0 } },
    "n6b": { "id": "n6b", "name": "FightCornered", "title": "Fight Cornered", "description": "", "properties": {}, "display": { "x": 0, "y": 0 } },
    "n7": { "id": "n7", "name": "Sequence", "title": "Attack", "description": "", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n8", "n9"] },
    "n8": { "id": "n8", "name": "IsPlayerInRange", "title": "Is Player In Range?", "description": "", "properties": { "range": 2 }, "display": { "x": 0, "y": 0 } },
    "n9": { "id": "n9", "name": "AttackPlayer", "title": "Attack Player", "description": "", "properties": {}, "display": { "x": 0, "y": 0 } },
    "n10": { "id": "n10", "name": "Sequence", "title": "Chase", "description": "", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n11", "n12"] },
    "n11": { "id": "n11", "name": "IsPlayerVisible", "title": "Is Player Visible?", "description": "", "properties": { "distance": 10 }, "display": { "x": 0, "y": 0 } },
    "n12": { "id": "n12", "name": "MoveToPlayer", "title": "Move To Player", "description": "", "properties": { "speed": 4 }, "display": { "x": 0, "y": 0 } },
    "n13": { "id": "n13", "name": "Sequence", "title": "Patrol", "description": "", "properties": {}, "display": { "x": 0, "y": 0 }, "children": ["n14", "n15", "n16"] },
    "n14": { "id": "n14", "name": "MoveToWaypoint", "title": "Move To Waypoint", "description": "", "properties": { "speed": 2 }, "display": { "x": 0, "y": 0 } },
    "n15": { "id": "n15", "name": "Wait", "title": "Wait", "description": "", "properties": { "milliseconds": 2000 }, "display": { "x": 0, "y": 0 } },
    "n16": { "id": "n16", "name": "NextWaypoint", "title": "Next Waypoint", "description": "", "properties": {}, "display": { "x": 0, "y": 0 } }
  }
}
