WitchSpace ship populating

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

WitchSpace ship populating

Post by Killer Wolf »

dunno if this *is* a scripty thing.

my new Vampire variant, the Spectre, is a NPC-only military ship that is purely a bug-killer designed for Damage, Inc. How do i give it a role that will amke sure it only appears 95% of the time (say) when you're in WS? A few might be seen in systems, but given the name etc, i want them to be somewhat urban-legendy.
would it have to be a script thing?
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 »

Yes, it is a script thing.

In your spawning script, make sure that you have a condition that says

Code: Select all

if(system.isInterstellarSpace)
This will only be true in interstellar space, so everything after this condition is only executed if the player is in interstellar space.

If you, on the other hand, want to spawn a ship only in normal space, you have to insert the opposite condition

Code: Select all

if(!system.isInterstellarSpace)
'!' means "not" in JS-syntax.

It's the same as the "planet_number equal -1" in legacy scripting.
User avatar
Nemoricus
---- E L I T E ----
---- E L I T E ----
Posts: 388
Joined: Mon May 18, 2009 8:51 pm

Post by Nemoricus »

Also, if you want them to show up 95% of the time, just have a line like:

Code: Select all

if(Math.random() < .95)
Dream as if you'll live forever
Live as if you'll die tomorrow
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

And to combine the two:

Code: Select all

this.shipWillExitWitchspace = function() {

  if(system.isInterstellarSpace && Math.random() < .95) {
    // spawn the ship!

        ...

  }

      ...

}
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

Post by Killer Wolf »

sweet, cheers :-)
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

Re: WitchSpace ship populating

Post by Killer Wolf »

Right, it's not working :-(

was using my standard script that uses addsystemships, log said it had, nowt appeared. reading wiki, it seemed that command would stick em somewhere in the normal spacelanes, which might not work properly in Witchspace?
finally tried spawn, which wiki says adds them "near the ship". well, i can't see them! again, log says they've been added, but there's nowt on my scanner.

what am i doing wrong?


as a sideline, i have wasps in witchspace - great allies for fighting thargs, but those buggers zip around and hoover up alien items like it was free jam, there's never any left for me! >:-/
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: WitchSpace ship populating

Post by Commander McLane »

Can you post the exact snippet from your script? I think that would make a diagnosis much easier.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: WitchSpace ship populating

Post by Thargoid »

Killer Wolf wrote:
as a sideline, i have wasps in witchspace - great allies for fighting thargs, but those buggers zip around and hoover up alien items like it was free jam, there's never any left for me! >:-/
Of course they do - bringing me back my robot fighters and some profit :twisted: Why d'ya think I programmed them that way :)

As McLane says, post some script and we'll take a look...
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: WitchSpace ship populating

Post by Cody »

A daft thought, KW… which version of Oolite are you using for testing this?
I ask as some screenshots that you posted recently were using dev version 1.74.0.3424, which is quite old… could this be a reason why your script isn’t working?
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

Re: WitchSpace ship populating

Post by Killer Wolf »

it is that version, i've not updated yet. i'll grab the new version and try it tonight before i stick my code snippet up. i thought "spawn" was pretty basic and old as commands go, and it is actually spawing, just not around the ship :-/
cheers
User avatar
Cody
Sharp Shooter Spam Assassin
Sharp Shooter Spam Assassin
Posts: 16081
Joined: Sat Jul 04, 2009 9:31 pm
Location: The Lizard's Claw
Contact:

Re: WitchSpace ship populating

Post by Cody »

Killer Wolf wrote:
i thought "spawn" was pretty basic and old as commands go, and it is actually spawing, just not around the ship :-/
It’s not so much that… it’s whether snippets of code, as from Kaks above, might not work in the older version.
(But I don’t really know what I’m talking about, of course).
I would advise stilts for the quagmires, and camels for the snowy hills
And any survivors, their debts I will certainly pay. There's always a way!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: WitchSpace ship populating

Post by another_commander »

If you are developing OXPs, it is recommended that you test them with the latest official version and trunk too. This is especially important now that we have switched the JS engine between releases. It may be quite disappointing going through a big effort to make a killer-script OXP, only to find out that it fails to work with the version of the game that's about to become official soon.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: WitchSpace ship populating

Post by Thargoid »

Not to mention having to upgrade the back-catalogue (again)...
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Re: WitchSpace ship populating

Post by DaddyHoggy »

Thargoid wrote:
Not to mention having to upgrade the back-catalogue (again)...
Explains the choice of avatar.... :wink:
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

Re: WitchSpace ship populating

Post by Killer Wolf »

LOL, alright, i think the machine's just trying to annoy me again.
currently, i have two scripts relevant to this post. My Cobra MkIV OXP runs this :

Code: Select all

// Configuration -- customize here 
this.role = "c4"; 
this.count = 8; 

// Standard attributes 
this.name           = "Spawn-" + this.role; 
this.author         = "Jens Ayton"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0.1"; 
this.description    = "Script to make several ships of a given role appear outside the station upon launching." 


this.shipWillLaunchFromStation = function() 
{ 
    system.legacy_addSystemShips(this.role, this.count, 1.0); 
    log("testscript.spawn", "Generated " + this.count + " " + this.role + " for testing purposes."); 
} 
this is my standard testy thing to gen up some craft when i launch so i can see what they look like. Currently, the Cobras have a pirate AI so you get a bit of a barney when you launch. this works. i had the same script for the Spectres, and it worked too.
as per this thread, i produced this for the Witchspace thing :

Code: Select all

// Configuration -- customize here 
this.role = "spectre"; 
this.count = 8; 

// Standard attributes 
this.name           = "Spawn-" + this.role; 
this.author         = "Jens Ayton"; 
this.copyright      = "This script is hereby placed in the public domain."; 
this.version        = "1.0.1"; 
this.description    = "Script to make several ships of a given role appear outside the station upon launching." 


this.shipWillExitWitchspace = function() 
{
  if(system.isInterstellarSpace && Math.random() < .95) 
  {
     spawn: this.role, this.count; 
     log("testscript.spawn", "Generated " + this.count + " " + this.role + " for testing purposes."); 

  }

}
i used "spawn" because the "system.legacy_addSystemShips" bit didn't work : well, the log said it worked, but i'll be buggered if i know where the Spectres were spawning :-/

so anyway, i've d/l'd the current trunk, #4053. and there's some oddness. when i hit Witchspace, there's some Thargoids, my Nest, and now, my cluster of Cobras appears here too! And...the Spectres didn't, though they're still genned, according to the log. Seeing the Cobra script worked (it shouldn't have, it uses launch, not WS exit as a trigger), i changed the Spectre script to use system.legacy_addSystemShips again instead of spawn, cos if it works for the Cobras, it'll work for the Spectres too, right? Wrong. Still genned up, still nowhere to be seen.

in further tests, i did a clean jump to Zaonce. as soon as i arrived, the Cobra script ran and genned up the ships right beside me. This hasn't happened before and it only seems to have happened once but at the same time i'm 90% sure i got a flying-in-reverse ship, cos a viper appeared at great speed and his engine plume was on the wrong side for his direction of travel; sadly, those Cobra pilots took my attention before i could confirm fully.
after that, i tried taking the isInterstellaspace thing out, it still didn't work. :-(


aside from that, Griff's OXP has caused a couple log entries :
shader.load.fullModeFailed]: ----- WARNING: Could not build shader griff_normalmap_ships.vertex/griff_cobra_mk1_r_channel_decals.fragment in full complexity mode, trying simple mode.
[shader.load.fallbackSuccess]: Simple mode fallback successful.
[shader.link.failure]: ***** ERROR: GLSL shader program linking failed for griff_normalmap_ships.vertex/griff_cobra_mk1_r_channel_decals.fragment:
>>>>> GLSL log:
Fragment shader(s) failed to link, vertex shader(s) failed to link.
ERROR: error(#277) Symbol 'gl_TexCoord[0]' usage doesn't match between two stages
ERROR: error(#277) Symbol 'gl_TexCoord[0]' usage doesn't match between two stages


[shader.load.fullModeFailed]: ----- WARNING: Could not build shader griff_normalmap_ships.vertex/griff_cobra_mk1_r_channel_decals.fragment in full complexity mode, trying simple mode.
[shader.load.fallbackSuccess]: Simple mode fallback successful.
[loading.complete]: ========== Loading complete. ==========
Post Reply