Page 1 of 2

WitchSpace ship populating

Posted: Thu Dec 30, 2010 5:56 pm
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?

Posted: Thu Dec 30, 2010 6:18 pm
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.

Posted: Thu Dec 30, 2010 6:32 pm
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)

Posted: Thu Dec 30, 2010 9:08 pm
by Kaks
And to combine the two:

Code: Select all

this.shipWillExitWitchspace = function() {

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

        ...

  }

      ...

}

Posted: Fri Dec 31, 2010 8:36 am
by Killer Wolf
sweet, cheers :-)

Re: WitchSpace ship populating

Posted: Wed Jan 12, 2011 8:30 pm
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! >:-/

Re: WitchSpace ship populating

Posted: Wed Jan 12, 2011 9:19 pm
by Commander McLane
Can you post the exact snippet from your script? I think that would make a diagnosis much easier.

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 6:30 am
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...

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 11:14 am
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?

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 12:57 pm
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

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 2:13 pm
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).

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 2:17 pm
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.

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 2:28 pm
by Thargoid
Not to mention having to upgrade the back-catalogue (again)...

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 2:50 pm
by DaddyHoggy
Thargoid wrote:
Not to mention having to upgrade the back-catalogue (again)...
Explains the choice of avatar.... :wink:

Re: WitchSpace ship populating

Posted: Thu Jan 13, 2011 7:42 pm
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. ==========