// Returns failure if enemy in sights or if agent was lost. // Returns success if enemy was found. // Returns running if agent is walking towards last seen destination. public static Node Tree_FollowEnemy(N_AgentNode.AgentType agent) { N_Sequence followSequence = new N_Sequence(); followSequence.AddLast(new N_DecFlip(new N_IsEnemyVisible(agent))); followSequence.AddLast(new N_FollowEnemy(agent)); followSequence.IsSubtree = true; return(followSequence); }
// Returns success if agent was shot, no enemy was in sight and agent turned around. // Returns failure otherwise. public static Node Tree_TurnWhenShot(N_AgentNode.AgentType agent) { N_Sequence turnSequence = new N_Sequence(); turnSequence.AddLast(new N_WasShot(agent)); turnSequence.AddLast(new N_DecFlip(new N_IsEnemyVisible(agent))); turnSequence.AddLast(new N_TurnAround(agent)); turnSequence.IsSubtree = true; return(turnSequence); }
// Returns success if no enemy is in sights *** succ or fail? // Returns success if in sights and agent shot. public static Node Tree_ShootAtEnemy(N_AgentNode.AgentType agent) { N_Sequence shootTree = new N_Sequence(); shootTree.AddLast(new N_IsEnemyVisible(agent)); shootTree.AddLast(new N_ShootAtEnemy(agent)); N_DecSuccess success = new N_DecSuccess(shootTree); success.IsSubtree = true; return(success); //return shootTree; }
// Returns success if ammo full. // Returns failure if not beneath threshold. // Returns running if in process of reloading. public static Node Tree_ReloadIfLow(N_AgentNode.AgentType agent, int threshold) { // Create nodes. N_AmmoThreshold ammoCheck = new N_AmmoThreshold(agent, threshold); N_Reload reload = new N_Reload(agent); N_Sequence reloadSequence = new N_Sequence(); // Add nodes to sequence. Threshold must be true before attemtping to reload. reloadSequence.AddLast(ammoCheck); reloadSequence.AddLast(reload); reloadSequence.IsSubtree = true; return(reloadSequence); }
// Sequence for moving by patroling or kiting. // If an enemy is spotted, there's a probability of the agent either patroling. // or kiting. If no enemy, always patrol. // Returns success if path found and started. // Returns running if in process of walking towards destination. public static Node Tree_PatrolOrKite(N_AgentNode.AgentType agent) { N_ProbabilitySelector kiteOrPatrol = new N_ProbabilitySelector(); kiteOrPatrol.AddLast(new N_Kite(agent)); kiteOrPatrol.AddLast(new N_Patrol(agent)); //N_DecSuccess kiteOrPatrolSuccess = new N_DecSuccess(kiteOrPatrol); N_Sequence enemyThenKiteOrPatrol = new N_Sequence(); enemyThenKiteOrPatrol.AddLast(new N_IsEnemyVisible(agent)); enemyThenKiteOrPatrol.AddLast(kiteOrPatrol); //N_DecSuccess patrolSuccess = new N_DecSuccess(new N_Patrol(agent)); N_Selection enemyOrPatrol = new N_Selection(); enemyOrPatrol.AddLast(enemyThenKiteOrPatrol); enemyOrPatrol.AddLast(new N_Patrol(agent)); enemyOrPatrol.IsSubtree = true; return(enemyOrPatrol); }