turning station

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

Moderators: another_commander, winston

Post Reply
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

turning station

Post by Commander McLane »

Has anybody an idea on this one:

In Anarchies.oxp the Salvage Gang is a huge asteroid which is inhabited by a gang of, well, salvagers. The asteroid is a wonderful model made by Killer Wolf. It has only one strange behaviour: when spawned by the script it first turns around 180 degrees and then faces away from the planet. You can see it turning. I have no idea why.

Anybody of you?
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

I can only think of the AI having it's destination set to planet and PerformFaceDestination.
It probably is spawned facing away from planet.

IIRC the asteroid was used originally in asteroid-storm? Which has the 'roid intercepting the planet/mainstation.

Probably you intended to have it to face away from planet when spawned.
and set up the spawning-shipdata accordingly.
Riding the Rocket!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

It's no longer a model from asteroid storm, but a gorgeous newly designed asteroid by Killer Wolf, and I gave it an AI that is derived from stationAI, so no performFaceDestination.

Anyway, here is the AI:

Code: Select all

{
    "DEFENSE_MODE" = {
        ATTACKED = (setTargetToPrimaryAggressor, launchDefenseShip, groupAttackTarget, increaseAlertLevel); 
        ENTER = (deployEscorts); 
        EXIT = (); 
        "RED_ALERT" = (launchDefenseShip); 
        "YELLOW_ALERT" = ("setStateTo: IDLE"); 
        "CONDITION_YELLOW" = ("setStateTo: IDLE"); 
        "CONDITION_GREEN" = ("setStateTo: CHECK_FOR_DEBRIS"); 
        "INCOMING_MISSILE" = (fireECM, launchDefenseShip, increaseAlertLevel); 
        "TARGET_DESTROYED" = ("pauseAI: 10.0", "setStateTo: IDLE"); 
        "TARGET_LOST" = ("pauseAI: 10.0", "setStateTo: IDLE"); 
        "NO_TARGET" = ("pauseAI: 10.0", "setStateTo: IDLE"); 
        UPDATE = (launchDefenseShip, groupAttackTarget, "pauseAI: 2.0"); 
    }; 
    "CHECK_FOR_DEBRIS" = {
        ENTER = ("setDesiredRangeTo: 25600", scanForLoot); 
        UPDATE = ("setDesiredRangeTo: 25600", scanForLoot, "pauseAI: 10.0"); 
        "TARGET_FOUND" = (launchScavenger, "setStateTo: IDLE"); 
        "NOTHING_FOUND" = ("setStateTo: IDLE", "pauseAI: 10.0"); 
        EXIT = (); 
        ATTACKED = (setTargetToPrimaryAggressor, launchDefenseShip, increaseAlertLevel, "setStateTo: DEFENSE_MODE"); 
        "INCOMING_MISSILE" = (fireECM, launchDefenseShip, increaseAlertLevel); 
    }; 
    GLOBAL = {ENTER = (setUpEscorts, performEscort, "setStateTo: IDLE"); EXIT = (); UPDATE = (); }; 
    IDLE = {
        ATTACKED = (setTargetToPrimaryAggressor, launchDefenseShip, increaseAlertLevel, "setStateTo: DEFENSE_MODE"); 
        ENTER = (decreaseAlertLevel, "setStateTo: CHECK_FOR_DEBRIS"); 
        EXIT = (); 
        "INCOMING_MISSILE" = (fireECM, increaseAlertLevel, launchDefenseShip, "setStateTo: DEFENSE_MODE"); 
        UPDATE = (decreaseAlertLevel, "setStateTo: CHECK_FOR_DEBRIS"); 
    }; 
}
And here the shipdata-entry:

Code: Select all

	<key>salvage-gang</key>
	<dict>
		<key>ai_type</key>
		<string>salvageGangAI.plist</string>
		<key>bounty</key>
		<integer>0</integer>
		<key>cargo_type</key>
		<string>CARGO_NOT_CARGO</string>
		<key>defense_ship_role</key>
		<string>salvageGang_defender</string>
		<key>energy_recharge_rate</key>
		<real>30</real>
		<key>equipment_price_factor</key>
		<real>2</real>
		<key>equivalent_tech_level</key>
		<integer>6</integer>
		<key>escorts</key>
		<integer>0</integer>
		<key>escort-ship</key>
		<string>sentinel-asteroid</string>
		<key>forward_weapon_type</key>
		<string>WEAPON_NONE</string>
		<key>frangible</key>
		<true/>
		<key>has_ecm</key>
		<true/>
		<key>has_escape_pod</key>
		<false/>
		<key>has_scoop</key>
		<false/>
		<key>hasShipyard</key>
		<false/>
		<key>likely_cargo</key>
		<integer>0</integer>
		<key>max_cargo</key>
		<integer>0</integer>
		<key>max_defense_ships</key>
		<integer>4</integer>
		<key>max_energy</key>
		<real>3000</real>
		<key>max_flight_pitch</key>
		<real>8</real>
		<key>max_flight_roll</key>
		<real>8</real>
		<key>max_flight_speed</key>
		<real>0</real>
		<key>max_missiles</key>
		<integer>0</integer>
		<key>max_scavengers</key>
		<integer>3</integer>
		<key>missiles</key>
		<integer>0</integer>
		<key>model</key>
		<string>salvager-rock.dat</string>
		<key>name</key>
		<string>Salvage Gang</string>
		<key>port_radius</key>
		<real>500</real>
		<key>roles</key>
		<string>salvage_gang station(0.00001)</string>
		<key>scanClass</key>
		<string>CLASS_ROCK</string>
		<key>smooth</key>
		<true/>
		<key>subentities</key>
		<array>
			<string>hacker-dock 0 -58.6 -500 1 0 0 0</string>
			<string>salvager-tunnel 0 0 0 1 0 0 0</string>
			<string>salvager-inside 0 0 0 1 0 0 0</string>
			<string>salvager-bighut 0 0 0 1 0 0 0</string>
			<string>salvager-smallhut 0 0 0 1 0 0 0</string>
			<string>salvager-sidehut 0 0 0 1 0 0 0</string>
			<string>salvager-fronthut 0 0 0 1 0 0 0</string>
			<string>salvager-crane 0 0 0 1 0 0 0</string>
			<string>salvager-cutter 0 0 0 1 0 0 0</string>
			<string>*FLASHER* -95 -56.5 -525 60.0 1 -0.50 12</string>
			<string>*FLASHER* -95 -56.5 -575 75.0 1 -0.60 12</string>
			<string>*FLASHER* -95 -56.5 -625 90.0 1 -0.70 12</string>
			<string>*FLASHER* -95 -56.5 -675 105.0 1 -0.80 12</string>
			<string>*FLASHER* -95 -56.5 -725 120.0 1 -0.90 12</string>
			<string>*FLASHER* 95 -56.5 -525 60.0 1 -0.50 12</string>
			<string>*FLASHER* 95 -56.5 -575 75.0 1 -0.60 12</string>
			<string>*FLASHER* 95 -56.5 -625 90.0 1 -0.70 12</string>
			<string>*FLASHER* 95 -56.5 -675 105.0 1 -0.80 12</string>
			<string>*FLASHER* 95 -56.5 -725 120.0 1 -0.90 12</string>
			<string>*FLASHER* 0 -72.5 -750 30.0 1 0.5 12</string>
			<string>*FLASHER* 0 -40.5 -750 30.0 1 0.5 12</string>
			<string>*FLASHER* 16 -56.5 -750 30.0 1 0.0 12</string>
			<string>*FLASHER* -16 -56.5 -750 30.0 1 0.0 12</string>
			<string>*FLASHER* 7 365 277 60.0 1 0.0 10</string>
			<string>*FLASHER* 7 365 120 60.0 1 0.25 10</string>
			<string>*FLASHER* 206 365 120 60.0 1 0.5 10</string>
			<string>*FLASHER* 206 365 277 60.0 1 0.75 10</string>
		</array>
		<key>thrust</key>
		<real>100</real>
		<key>weapon_energy</key>
		<real>0.0</real>
		<key>weapon_offset_x</key>
		<real>0.0</real>
	</dict>
Most values are taken from stations and/or rock hermits. If you spot anything which could cause this turning behaviour I would be grateful for a hint.

And it's added by addShipsAt, so it should just be facing the planet (which it actually does, before turning around).

Help still appreciated!

------

EDIT: As I read it after posting I see there is still a performEscort in the AI. It was one of my (continuing) efforts to get the escorting sentinel asteroids to work (which they still don't do). Perhaps this is the cause of the problem. I'll take it out and see what happens.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Okay, taken the performEscort out, and now it's facing in the right direction. So it seems that was indeed the cause of the problem.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

code request:

SetTargetAsMother

Makes the current target of the entity its Mother. (or Leader for that matter)

:D
Riding the Rocket!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

There is another problem with orientation. The Hacker Outpost will appear at random locations off the corridor, but I want it to face the planet. So I use the spawnShip-method and created 4 shipdata-entries of hacker-outpost1..4. They have got the following spawn-entries (copying only the relevant part of the code):

Code: Select all

	<key>hacker-outpost1</key>
	<dict>
		<key>spawn</key>
		<dict>
			<key>position</key>
			<string>wpm 0 0 -150000</string>
			<key>facing_position</key>
			<string>pwm 0 0 0</string>
		</dict>
	</dict>
	<key>hacker-outpost2</key>
	<dict>
		<key>like_ship</key>
		<string>hacker-outpost1</string>
		<key>spawn</key>
		<dict>
			<key>position</key>
			<string>pwm 0 0 -300000</string>
			<key>facing_position</key>
			<string>pwm 0 0 0</string>
		</dict>
	</dict>
	<key>hacker-outpost3</key>
	<dict>
		<key>like_ship</key>
		<string>hacker-outpost1</string>
		<key>spawn</key>
		<dict>
			<key>position</key>
			<string>pwm 0 250000 250000</string>
			<key>facing_position</key>
			<string>pwm 0 0 0</string>
		</dict>
	</dict>
	<key>hacker-outpost4</key>
		<key>spawn</key>
		<dict>
			<key>position</key>
			<string>psm 400000 400000 400000</string>
			<key>facing_position</key>
			<string>psm 0 0 0</string>
		</dict>
	</dict>
That should spawn the outpost at one of the four given positions, but always facing the planet. But it doesn't! Also it isn't facing in random directions, but always in the same one: along the wpm z-axis. So hacker-outpost1 is facing the planet. And the facing of all the other variants is parallel to that one. If you launch from any of them with the coordinates displayed you see always the same: the last value in the pwm-system decreases, the others are stable. I have no idea what's wrong.

First I thought, perhaps the facing_position is too close for the engine to compute it usefully. So I put it backward, e.g. for hacker-outpost4 I changed it to <string>psm -1000000 -1000000 -1000000</string>, which is exactly the same direction, but. No difference.

The strange thing is: in Equilibrium.oxp I am spawning a station with the following position and facing:

Code: Select all

		<key>spawn</key>
		<dict>
			<key>position</key>
			<string>psm 0 0 1000530</string>
			<key>facing_position</key>
			<string>psm 0 0 0</string>
		</dict>
And this one works. I can't figure out the difference between the two of them!

Anyway, after A_H posted here about setting the destination to planet and performFaceDestination, I thought that might be a way to force my hacker outpost to face the planet. So I inserted the following methods into the GLOBAL_part of its AI:

Code: Select all

    GLOBAL = {ENTER = (findNearestPlanet, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Didn't work. Now the outpost faced in random directions. Perhaps the planet has to be made the current destination first:

Code: Select all

    GLOBAL = {ENTER = (findNearestPlanet, setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Again random directions, perhaps with a preference to face away from the planet. Ah, maybe it doesn't work all in the ENTER-part. So insert a TARGET_FOUND:

Code: Select all

    GLOBAL = {ENTER = (findNearestPlanet); TARGET_FOUND = (setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Still nothing. A quick insert of a commsMessage reveals that the AI-message TARGET_FOUND is never received! Why that? Hm, there is no range defined yet. Okay, give the hacker outpost a biiig scanner_range in shipdata. Still nothing.

Perhaps findNearestPlanet doesn't return TARGET_FOUND, but PLANET_FOUND. So changed that:

Code: Select all

    GLOBAL = {ENTER = (findNearestPlanet); PLANET_FOUND = (setDestinationToTarget, performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
Nope. No result. I am running out of ideas. Ah, there is another useful AI-method, called setCoordinates:(NSString *)system_x_y_z, which is supposed to set the destination coords, exactly what I need. So everything taken back, instead it is:

Code: Select all

    GLOBAL = {ENTER = ("setCoordinates: pwm 0 0 0", performFaceDestination, "setStateTo: IDLE"); EXIT = (); UPDATE = (); };
And ... again a certain randomization of the facing directions, but all of them more or less away from the planet.

Now I'm really stuck. Why the heck is this bl***y hacker outpost so persistantly refusing to face into the one direction I want it to??? What am I doing wrong here? I can't see it.

Help!
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

Don't see anything wrong with the spawning method or coordinates, they SHOULD work.
You ARE using SPAWN method to place the outposts aren't you?

Check routeXtraderAI for hints...
edit:

Code: Select all

setCourseToPlanet (sets planet as destination), performFaceDestination
not neccecary for facing something, but for setting targets as destinations:

Code: Select all

ENTER = (setTargetToStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
       "COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
       "WAYPOINT_SET" = ("setStateTo: GO_TO_WAYPOINT");
Last edited by Arexack_Heretic on Mon Apr 02, 2007 11:12 am, edited 1 time in total.
Riding the Rocket!
User avatar
Uncle Reno
---- E L I T E ----
---- E L I T E ----
Posts: 648
Joined: Mon Apr 24, 2006 12:54 pm
Location: UK

Post by Uncle Reno »

I've not even installed this OXP myself, but would Giles' racing rings OXP be useful to look at? I'm assuming the rings must all face in directions that Giles wanted them to so perhaps his script could be helpful. :shrug:
Apologies if it turns out to be a red herring though. :)
"Get back or I unleash my lethal spotted batoid!!"

What I do when not reading the Oolite bulletin board!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

@ A_H: Yes, I am. Here's the relevant part of my test-script:

Code: Select all

		{
			conditions = ("status_string equal STATUS_LAUNCHING");
			do = (
				sendAllShipsAway,
				"spawnShip: hacker-outpost3",
				"addSystemShips: salvage_gang 1 0.5",
				"addSystemShips: salvager_tugger 1 0.4"
			);
		},
I use it to test hackers and salvagers at the same time.

Oh, and I forgot to mention: I also tried all the other methods that set the planet as target, like setCourseToPlanet (and there was another one, I think). Didn't work as well. That's why I'm feeling so completely stuck.

I haven't tried out setTargetToStation however. Will do that. I don't mind whether the hackers are facing the planetary core or the station. And there is a small random aberration anyway.

I really have started wondering whether something within my Oolite can be broken. Have even re-installed it. Because there is another unrelated, but evenly weird issue: I made my ImpCourier smooth in its shipdata, but it got dark. So I set the smooth-method to <false/>. Now if I fire up Oolite and use external views, sometimes my ship still is dark, sometimes bright again, but always smoothed! Very weird!!!
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1878
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

That IS weird.
I have a related texture issue with the flamed-krait from paintjopbs-oxp;
the underside has inverted colours. (blueflames in stead of oragnge ones)
(since the first windows version, so it's a pretty old bug)

Try the role-spawn method, maybe the shipkey-spawn is broken...?
Ahruman is wrestling with the shipadding too by the way.
Riding the Rocket!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

I know, I have posted a loooooooooooooooong explanation of all the ship-creating methods in his thread, hopefully giving the complete and ultimative answer to all questions that ever could arise around this issue. :wink:
Post Reply