How does setDesiredRangeTo work?

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

Moderators: winston, another_commander

Post Reply
User avatar
Dr. Nil
---- E L I T E ----
---- E L I T E ----
Posts: 983
Joined: Thu Sep 28, 2006 5:11 pm
Location: Nearest Hoopy Casino
Contact:

How does setDesiredRangeTo work?

Post 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?
Image

300 billboards in Your Ad Here!
Astromines and more in Commies.
AVAILABLE HERE along with other Oolite eXpansion Packs.
dajt
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 364
Joined: Tue Aug 17, 2004 7:05 am
Location: Orange, NSW, Australia

Post by dajt »

The units are metres.
Regards,
David Taylor.
User avatar
LittleBear
---- E L I T E ----
---- E L I T E ----
Posts: 2882
Joined: Tue Apr 04, 2006 7:02 pm
Location: On a survey mission for GalCop. Ship: Cobra Corvette: Hidden Dragon Rated: Deadly.

Post 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. :?
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
User avatar
Dr. Nil
---- E L I T E ----
---- E L I T E ----
Posts: 983
Joined: Thu Sep 28, 2006 5:11 pm
Location: Nearest Hoopy Casino
Contact:

Post 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.
Image

300 billboards in Your Ad Here!
Astromines and more in Commies.
AVAILABLE HERE along with other Oolite eXpansion Packs.
Post Reply