Expert eyes needed.

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Expert eyes needed.

Post by Smivs »

Hi all,
I need a trader AI but for a ship which avoids combat at all costs. Below is a blend of route1traderAI and traderinterceptAI which I hope will do this, but I do sometimes get bogged down with AIs.
If anyone would be kind enough to look this over for me, I'd be really grateful.

Code: Select all

{
	GLOBAL = 
	{
		ENTER = ("setStateTo: HEAD_FOR_PLANET"); 
	}; 
	"HEAD_FOR_PLANET" = 
	{
		ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.65", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"AEGIS_CLOSE_TO_MAIN_PLANET" = ("setStateTo: GO_TO_STATION");
		"CLOSE_TO_SECONDARY_PLANET" = ("setStateTo: GO_TO_SUB_STATION");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, "setStateTo: GO_TO_STATION");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: GO_TO_STATION");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		RESTARTED = (checkAegis);
		UPDATE =
		(
			setCourseToPlanet,
			"setDesiredRangeTo: 30000.0",
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_STATION" = 
	{
		ENTER = (setTargetToSystemStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToSystemStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_SUB_STATION" = 
	{
		ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
FLEE = 
	{
		ENTER = ("setDesiredRangeTo: 25600", performFlee); 
		ATTACKED = (fightOrFleeHostiles); 
		FIGHTING = (setTargetToPrimaryAggressor, "setStateTo: FLEE");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE", "pauseAI: 10");
		DEPLOYING_ESCORTS = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
		"TARGET_LOST" = ("setStateTo: GLOBAL"); 
		"TARGET_DESTROYED" = ("setStateTo: GLOBAL"); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = (performIdle, exitAI); 
	}; 
	"FLEE_FOR_MISSILE" = 
	{
		ENTER = ("setDesiredRangeTo: 25600", broadcastDistressMessage, performFlee, "pauseAI: 5"); 
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeHostiles); 
		"TARGET_LOST" = (scanForHostiles); 
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: GLOBAL", fightOrFleeHostiles);
		"NOTHING_FOUND" = (exitAI);
		"TARGET_DESTROYED" = (performIdle, exitAI); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = (performIdle, exitAI); 
		"UPDATE" = (fightOrFleeMissile, "pauseAI: 10");
	}; 
	"INCOMING_MISSILE" = 
	{
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeMissile, fightOrFleeHostiles); 
		"UPDATE" = (setTargetToPrimaryAggressor, fightOrFleeMissile, "setStateTo: FLEE_FOR_MISSILE"); 
	}; 
}
Commander Smivs, the friendliest Gourd this side of Riedquat.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck »

Under Flee section you have:
DEPLOYING_ESCORTS = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");

...Yet I don't see anything else that uses the FLEE_WITH_ESCORTS messageString. Is that used in an external script? (...maybe for the escorts?)

You might want to increase the flee distances from 25600 to 26000-30000, in case of a half-hearted chaser.
"setSpeedFactorTo: 9.0" could also be added to flee using injectors.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Hi Switek,
Thanks for having a look. I actually meant to remove the 'flee with escorts' part as there are no escorts. Presumably I can just remove the whole section

Code: Select all

 DEPLOYING_ESCORTS = (setTargetToPrimaryAggressor, "setStateTo: FLEE_WITH_ESCORTS");
Your suggestions are also good, so the revised AI looks like this

Code: Select all

{
	GLOBAL = 
	{
		ENTER = ("setStateTo: HEAD_FOR_PLANET"); 
	}; 
	"HEAD_FOR_PLANET" = 
	{
		ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.65", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"AEGIS_CLOSE_TO_MAIN_PLANET" = ("setStateTo: GO_TO_STATION");
		"CLOSE_TO_SECONDARY_PLANET" = ("setStateTo: GO_TO_SUB_STATION");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, "setStateTo: GO_TO_STATION");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: GO_TO_STATION");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		RESTARTED = (checkAegis);
		UPDATE =
		(
			setCourseToPlanet,
			"setDesiredRangeTo: 30000.0",
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_STATION" = 
	{
		ENTER = (setTargetToSystemStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToSystemStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_SUB_STATION" = 
	{
		ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
FLEE = 
	{
		ENTER = ("setDesiredRangeTo: 30000", performFlee , "setSpeedFactorTo: 9.0"); 
		ATTACKED = (fightOrFleeHostiles); 
		FIGHTING = (setTargetToPrimaryAggressor, "setStateTo: FLEE");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE", "pauseAI: 10");
		"TARGET_LOST" = ("setStateTo: GLOBAL"); 
		"TARGET_DESTROYED" = ("setStateTo: GLOBAL"); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = (performIdle, exitAI); 
	}; 
	"FLEE_FOR_MISSILE" = 
	{
		ENTER = ("setDesiredRangeTo: 25600", broadcastDistressMessage, performFlee, "pauseAI: 5"); 
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeHostiles); 
		"TARGET_LOST" = (scanForHostiles); 
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: GLOBAL", fightOrFleeHostiles);
		"NOTHING_FOUND" = (exitAI);
		"TARGET_DESTROYED" = (performIdle, exitAI); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = (performIdle, exitAI); 
		"UPDATE" = (fightOrFleeMissile, "pauseAI: 10");
	}; 
	"INCOMING_MISSILE" = 
	{
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeMissile, fightOrFleeHostiles); 
		"UPDATE" = (setTargetToPrimaryAggressor, fightOrFleeMissile, "setStateTo: FLEE_FOR_MISSILE"); 
	}; 
}
I'm never sure if I need the quote marks (") for things like the "setSpeedFactorTo: 9.0"? I'm assuming I do.
Cheers,
Smivs.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Expert eyes needed.

Post by Eric Walch »

Smivs wrote:
Hi all,
I need a trader AI but for a ship which avoids combat at all costs. Below is a blend of route1traderAI and traderinterceptAI which I hope will do this
I made it two separate AIs so the traderInterceptAI could return to the state that called it. When you merge them to one single AI, you should decide what something like:

Code: Select all

"XXXXX" = (exitAI); 
Must do. There is nothing to exit now.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

Hi Eric,
I said I don't understand these too well!
I thought by taking the 'Flee' element from traderintercept and incorporating it into route1trader I could make a single AI that would get my ship from witchpoint to planet while avoiding combat/conflict, and that it would 'Exit' when it switched to the docking AI.
I notice that I have two "ExitAI" commands in the Flee and Fleeformissile sections, which are probably not helpful, as I presume it currently has nowhere to 'exit' to...is that what you meant.
So if I keep the single AI, does it still need to 'Exit' at some point?
This is the current attempt.

Code: Select all

{
	GLOBAL = 
	{
		ENTER = ("setStateTo: HEAD_FOR_PLANET"); 
	}; 
	"HEAD_FOR_PLANET" = 
	{
		ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.65", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"AEGIS_CLOSE_TO_MAIN_PLANET" = ("setStateTo: GO_TO_STATION");
		"CLOSE_TO_SECONDARY_PLANET" = ("setStateTo: GO_TO_SUB_STATION");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, "setStateTo: GO_TO_STATION");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: GO_TO_STATION");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		RESTARTED = (checkAegis);
		UPDATE =
		(
			setCourseToPlanet,
			"setDesiredRangeTo: 30000.0",
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_STATION" = 
	{
		ENTER = (setTargetToSystemStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToSystemStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
	"GO_TO_SUB_STATION" = 
	{
		ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToStation, "setAITo: dockingAI.plist");
		"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
		"NO_STATION_FOUND" = ("setAITo: exitingTraderAI.plist");
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: FLEE");
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.5 2.0"); 
		ATTACKED = ("setStateTo: FLEE"); 
		UPDATE = 
		(
			setTargetToStation,
			"setDesiredRangeTo: 5000.0",
			setDestinationToTarget,
			checkCourseToDestination,
			scanForHostiles,
			"pauseAI: 10.0"
		);
	}; 
FLEE = 
	{
		ENTER = ("setDesiredRangeTo: 30000", performFlee , "setSpeedFactorTo: 9.0"); 
		ATTACKED = (fightOrFleeHostiles); 
		FIGHTING = (setTargetToPrimaryAggressor, "setStateTo: FLEE");
		FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE", "pauseAI: 10");
		"TARGET_LOST" = ("setStateTo: GLOBAL"); 
		"TARGET_DESTROYED" = ("setStateTo: GLOBAL"); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = ("setStateTo: GLOBAL"); 
	}; 
	"FLEE_FOR_MISSILE" = 
	{
		ENTER = ("setDesiredRangeTo: 25600", broadcastDistressMessage, performFlee, "pauseAI: 5"); 
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeHostiles); 
		"TARGET_LOST" = (scanForHostiles); 
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: GLOBAL", fightOrFleeHostiles);
		"NOTHING_FOUND" = ("setStateTo: GLOBAL");
		"TARGET_DESTROYED" = ("setStateTo: GLOBAL"); 
		"INCOMING_MISSILE" = ("setStateTo: INCOMING_MISSILE", "randomPauseAI: 0.25 0.75"); 
		"REACHED_SAFETY" = (setStateTo: GLOBAL"); 
		"UPDATE" = (fightOrFleeMissile, "pauseAI: 10");
	}; 
	"INCOMING_MISSILE" = 
	{
		ATTACKED = ("setStateTo: GLOBAL", fightOrFleeMissile, fightOrFleeHostiles); 
		"UPDATE" = (setTargetToPrimaryAggressor, fightOrFleeMissile, "setStateTo: FLEE_FOR_MISSILE"); 
	}; 
}
Thanks,
Smivs.
Commander Smivs, the friendliest Gourd this side of Riedquat.
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Post by Switeck »

Under Flee again...is the 10 second pause here:
FLEEING = (setTargetToPrimaryAggressor, "setStateTo: FLEE", "pauseAI: 10");

...meant to prevent a conflict or just to be a very slow reaction?
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Post by Smivs »

:shock: I've got no idea where that came from, and I hadn't noticed it. Thanks. I'll remove it.
Commander Smivs, the friendliest Gourd this side of Riedquat.
Post Reply