Page 1 of 1

How does setDesiredRangeTo work?

Posted: Thu Jan 18, 2007 5:32 pm
by Dr. Nil
Range in...?

Inches?

Parsecs?

Whatever the game did it's last thing in?

:?

Consider this

Code: Select all

    "WAIT_FOR_PLAYER2" = {
	ENTER = ("setDesiredRangeTo: 250.0", "scanForNearestShipWithRole: player");
	"TARGET_FOUND" = (setTargetToFoundTarget, "commsMessage: [oohaulheyho]", "setStateTo: HEAD_FOR_CHECK_POINT_2" ); 
        "INCOMING_MISSILE" = (fireECM); 
	"NOTHING_FOUND" = ("setSpeedFactorTo: 0"); 
		UPDATE = ("scanForNearestShipWithRole: player", "pauseAI: 10.0");
		EXIT = ();
	}; 


    "HEAD_FOR_CHECK_POINT_1" = {
		ENTER = ("setCoordinates: pwu 0 0 0.85", setDestinationFromCoordinates, "setDesiredRangeTo: 100.0", "setSpeedFactorTo: 5.0", checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 5.0", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: WAIT_FOR_PLAYER2");
		"ATTACKED" = (performTumble);
        "INCOMING_MISSILE" = (fireECM); 
		UPDATE = ("pauseAI: 10.0");
		EXIT = ();
	};

    "WAIT_FOR_PLAYER1" = {
	ENTER = ("setDesiredRangeTo: 250.0", "scanForNearestShipWithRole: player");
	"TARGET_FOUND" = (setTargetToFoundTarget, "commsMessage: [oohaulheyho]", "setStateTo: HEAD_FOR_CHECK_POINT_1" ); 
        "INCOMING_MISSILE" = (fireECM);
	"NOTHING_FOUND" = ("setSpeedFactorTo: 0"); 
		UPDATE = ("scanForNearestShipWithRole: player", "pauseAI: 10.0");
		EXIT = ();
	}; 


    GLOBAL = {ENTER = ("setStateTo: WAIT_FOR_PLAYER1"); EXIT = (); UPDATE = (); }; 
}
The ship is spawned close to the player (for testing purposes). It goes straight from GLOBAL to WAIT_FOR_PLAYER1 where it sends it's message straight away (being at the edge of the radar) and moves on to HEAD_FOR_CHECK_POINT_1 goes to the waypoint where it changes AI state to WAIT_FOR_PLAYER2, stops and waits for the player to get really close, before sending it's message (here for test purposes) and starting it's engines up again.

Why does it find the player at the edge of the radar in the first wait state but needs him to be very close in the second when the range is set to the same value in those two states?

Posted: Thu Jan 18, 2007 9:57 pm
by dajt
The units are metres.

Posted: Thu Jan 18, 2007 10:06 pm
by LittleBear
Noticed this with minesweepers. When spawned by the beacon for testing, they knock out mines (by doing a scanforNearestShipwithRole: EQ_Q_MINE and then a scriptactionontarget) within 60 Km like there meant to with a scanner range of 60 km. However when I put them near a base, so they have been spawned for some time when thr player arrives, they don't react to a mine until within about 5km. Turned out ok, as I just put fields of the sweepers so the blind spots overlapped (and a cleaver player can find a blind spot!). Not sure why though. but think it has somthing to do with the scanforNearestShipWithRole bit. :?

Posted: Fri Jan 19, 2007 12:30 am
by Dr. Nil
Ok. I guess we will have to test when using this method to see how it reacts in different situations. It's clearly not meters all the time, since it manages to move on from WAIT_FOR_PLAYER1 already when it's at the edge of the radar.