Scripters cove

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

Moderators: winston, another_commander

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Replace vectorForward with either vectorRight or vectorUp. vectorForward is along the Z-axis (around which the station rotates anyway), so a rotation there won't help. But a rotation of Pi radians (aka 180 degrees) around either of the other two should do what you want.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2454
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripters cove

Post by Wildeblood »

That worked a treat. Thank you, Thargoid.
User avatar
BuggyBY
Dangerous
Dangerous
Posts: 108
Joined: Thu Feb 09, 2012 9:03 am

Re: Scripters cove

Post by BuggyBY »

Thargoid wrote:
Replace vectorForward with either vectorRight or vectorUp. vectorForward is along the Z-axis (around which the station rotates anyway), so a rotation there won't help. But a rotation of Pi radians (aka 180 degrees) around either of the other two should do what you want.
Shouldn't a 180 degree rotation point the ship back into the docking bay?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

He was spinning the station about (before launch), not the launching ship.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2454
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripters cove

Post by Wildeblood »

Thargoid wrote:
He was spinning the station about (before launch), not the launching ship.
Priority Launch READ ME wrote:
Place the Priority Launch OXP into your "AddOns" folder. At the main stations of planets with technical level 4 or higher, the station master will - for a small fee - re-align the space station to allow you an unimpeded launch in a direction away from the planet, directly into deep space. Station re-alignment takes 15 minutes of game time, but happens immediately for the player (similar to instant docking, which takes 20 minutes of game time).
This is quite handy for getting screen-shots of the station with the planet in the background, as well as for when I'm just being impatient. The next step to making it a polished OXP is making sure it only appears in the F3 screen at main stations, not at OXP stations. Is there a condition I can put in the equipment definition, or do I have to mess around giving it a script-changed tech level, and if the latter, how do I do that?
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

You can use conditions in Equipment.plist to achieve that. Specifically "conditions" = ( "dockedAtMainStation_bool equal YES" ); will limit it to main station only (you can limit the tech level in the normal way by the equipment's tech level, or alternatively with "systemTechLevel_number morethan 3" as an additional condition above). You can set multiple conditions in the array in the normal way, just comma-separate them.

It's coded in legacy scripting there (more full details are on this page on what is available). As yet that is the only way to do it for such conditions (in equipment and also in shipdata.plist conditions) but that may well be updated soon.

Links are to Maik's backup wiki as the main one is still down.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2454
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripters cove

Post by Wildeblood »

Thanks again, Thargoid. I've added Priority Launch to my cutesy tweaks list.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

Quick question...using this code in a worldscript (to add a station of sorts), how do I align it so the dock is facing the sun?

Code: Select all

system.addShipsToRoute(this.role2, this.count1, 0.8, "ws");
Commander Smivs, the friendliest Gourd this side of Riedquat.
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:

Re: Scripters cove

Post by Commander McLane »

Code: Select all

    // next line spawns the entity and puts it in a local variable 'myShip'
    var myShip = system.addShipsToRoute(this.role2, this.count1, 0.8, "ws")[0];
    // next line sets up a vector myShip --> sun
    var targetVector = system.sun.position.subtract(myShip.position).direction();
    // next line aligns the heading to the targetVector by rotating
    myShip.orientation = targetVector.rotationTo(new Vector3D(0,0,1));
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Scripters cove

Post by Smivs »

Thank you :)
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Pleb
---- E L I T E ----
---- E L I T E ----
Posts: 908
Joined: Sun Apr 29, 2012 2:23 pm
Location: United Kingdom

Re: Scripters cove

Post by Pleb »

I'm trying to switch the AI of all ships in the system that have a particular role but am not having much luck.

Code: Select all

		//Switch AIs on VirgoTech Inc. ships to attack Player:
		this._virgotechShipsArray = system.shipsWithRole("virgotech_defender");
		var i = 0;
		var count = this._virgotechShipsArray.length;
		for (i=0; i<count; i++)
		{
			this._virgotechShipsArray[i].setAI("traitor_pirateAI.plist");
		}
Does anyone know where I'm going wrong? This only makes one ship change its AI but the rest are the same... :?
Desktop PC: CPU: Intel i7-4790K Quad Core 4.4GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1080Ti RAM: 32GB DDR3

Laptop PC: CPU: Intel i5-10300H Quad Core 4.5GHz (Turbo-Charged) GPU: Nvidia GeForce GTX 1650 RAM: 32GB DDR4
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:

Re: Scripters cove

Post by Commander McLane »

Your code should be fine, and it's working here.

One suggestion, though: if you want to change the ships' AI permanently, Image switchAI() is what you're looking for. setAI() only adds the new AI on top of the current AI which is pushed to the AI stack. Thus the next exitAI command in your new AI will take the ship back to its original AI. switchAI() on the other hand erases the AI stack, making it impossible for the ship to fall back to its original AI.
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:

Re: Scripters cove

Post by Commander McLane »

Okay, here's a tricky one: is there a way to transfer information across a startUp event?

What do I want to do? There are several ways for the Asteroids3D-minigame to end:
  1. The player can destroy all the objects = game successfully ended;
  2. The player can dock while there are still objects left = game abandoned;
  3. The player can jump out while there are still objects left = game abandoned;
  4. The player can be killed during the game = new start at the last save game.
Asteroids3D.oxp has code to deal with the first three cases. For each case an appropriate mission screen is shown on next docking.

My question is: is it possible to show a mission screen in the last case as well? This means that the JS-engine somehow would have to know that the last player death did not occur during normal game play, but during an Asteroids3D-minigame. However, the startUp event removes all traces of what has happened before, clearing all variables, removing all objects and creating the Ooniverse anew from scratch. That's what it has to do, of course. But is it possible to circumvent this in any way for this special case? One possible way is not viable: I do not want the player to save their game after starting the Asteroids3D-minigame, and I absolutely don't want to force a save upon them. So I cannot use a missionVariable.

I don't see a solution to this (very special, I admit) problem, but perhaps one of you very clever people does?
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: Scripters cove

Post by Svengali »

Commander McLane wrote:
Okay, here's a tricky one: is there a way to transfer information across a startUp event?
If I get this right the only thing you can check is the player.ship.status. It is not failsafe though as the status changes.

Code: Select all

if(player.ship.status==='STATUS_DEAD') ...
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Scripters cove

Post by JensAyton »

Commander McLane wrote:
Okay, here's a tricky one: is there a way to transfer information across a startUp event?
If so, it’s a bug.
Post Reply