Boulders from asteroids question(s)

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

Moderators: another_commander, winston

User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Boulders from asteroids question(s)

Post by Smivs »

I'm baffled :?:
For an OXP idea I'm working on, I have an asteroid as a sub-entity of a ship - the idea is it's a space wreck and the asteroid has hit the ship at low speed and the ship is now 'crunched' onto the asteroid. So far so good. However I want to be able to salvage stuff from the ship by destroying it. Again so far so good. The problem is that sometimes the asteroid breaks into boulders during this and sometimes it doesn't. I would like to guarantee that the asteroid breaks into about 4-5 boulders every time.
The weird thing is, I tried increasing the 'likely cargo' to 100 to generate boulders on the destruction of the asteroid, and this works very well....except the 100 boulders appear about 10 000Km from the original asteroid. :shock:
Any thoughts/ideas?
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Boulders from asteroids question(s)

Post by Thargoid »

Have the asteroid entity not have boulders at all in the game-sense (it's one of the shipdata keys iirc), but on shipDied just have it spawn the boulders by script instead.
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: Boulders from asteroids question(s)

Post by Commander McLane »

That would be the no_boulders key, which should be set to yes.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Boulders from asteroids question(s)

Post by Thargoid »

Dat's der pebble...
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Boulders from asteroids question(s)

Post by Smivs »

Thanks chaps.
@Thargoid, I tried that but they seem to appear some distance from where the asteroid was, as opposed to the 'normal' formation of boulders that replace the asteroid in exactly the same position.
@McLane, if I set "no_boulders" = yes; won't that give me no boulders? I want the boulders. I'll try "no_boulders" = no; and see what happens.
Commander Smivs, the friendliest Gourd this side of Riedquat.
User avatar
Okti
---- E L I T E ----
---- E L I T E ----
Posts: 700
Joined: Sun Sep 26, 2010 1:51 pm
Location: A GH shop, near witchpoint to Oresrati in Galaxy 8

Re: Boulders from asteroids question(s)

Post by Okti »

Hi Smivs,

Try spawn function for the ship.shipDied event handler. That might help.
My OXP's
And Latest Mission Coyote's Run
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: Boulders from asteroids question(s)

Post by Commander McLane »

Smivs wrote:
Thanks chaps.
@Thargoid, I tried that but they seem to appear some distance from where the asteroid was, as opposed to the 'normal' formation of boulders that replace the asteroid in exactly the same position.
@McLane, if I set "no_boulders" = yes; won't that give me no boulders? I want the boulders. I'll try "no_boulders" = no; and see what happens.
'Yes' is the default, and does not guarantee boulders. Only 'no' guarantees that there will be none.

Setting it to 'no' only enables you to spawn them in another way, without worrying that the populator would interfere.

About the distance (10000 m, not km): please post the code snippet, then we can see if there is some error, or slip of logic, in it.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Boulders from asteroids question(s)

Post by Smivs »

It's mostly a C&P from the core shipdata.plist.

Code: Select all

"wreck_asteroid" =
	{
		ai_type = "dumbAI.plist";
		bounty = 10;
		cargo_type = "CARGO_NOT_CARGO";
		energy_recharge_rate = 0;
		density = 5;
		forward_weapon_type = "WEAPON_NONE";
		has_ecm = no;
		has_escape_pod = no;
		has_scoop = no;
		max_energy = 600;
		max_flight_pitch = 0.1;
		max_flight_roll = 0.1;
		max_flight_speed = 0;
		missiles = 0;
		model = "wreck_asteroid.dat";
		name = "Asteroid";
		roles = "asteroid";
		scan_class = "CLASS_ROCK";
		smooth = yes;
		thrust = 0;
		unpiloted = yes;
		weapon_energy = 0;
		materials =
		{
			"rock_SS.png" =
			{
			shininess = 2;
			specular_color = (0.1, 0.1, 0.1, 1.0);
			};
		};
		likely_cargo = 100;
		debris_role = "boulder";
		heat_insulation = 5;
	};
I've just given it a custom .dat and texture, and increased the energy to 600 to try and make it more durable. Ideally I'd like between 5 and 10 boulders when it 'goes'. I'm hitting it with military lasers which is probably not helping.
Oddly I cannot now reproduce the hundred boulders thing. It just explodes and leaves nothing anywhere.

On a related note, can sub-entities spawn items as a death action?
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: Boulders from asteroids question(s)

Post by Commander McLane »

Thargoid wrote:
Have the asteroid entity not have boulders at all in the game-sense (it's one of the shipdata keys iirc), but on shipDied just have it spawn the boulders by script instead.
Smivs wrote:
@Thargoid, I tried that.
Can you post the script where you tried to create the boulders inside the this.shipDied event handler? The shipdata are not really helpful for that (except for seeing that it's already missing the script key which is needed to activate the script in the first place.
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Boulders from asteroids question(s)

Post by Smivs »

I removed the script key when it didn't work.
The script key in the shipdata.plist was

Code: Select all

script = "spacewreck_boulders.js";
and the script (called "spacewreck_boulders.js") was

Code: Select all

this.shipDied = function ()
{
	this.ship.spawn("boulder");
};
I thought I'd start with one boulder, to keep it simple and I don't know how to script more than one anyway. That would have been my next question :roll:
The asteroid is a sub-entity, and I haven't been able to spawn anything as a death action from a sub-ent. Is this relevant?
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: Boulders from asteroids question(s)

Post by Commander McLane »

Smivs wrote:
I thought I'd start with one boulder, to keep it simple and I don't know how to script more than one anyway. That would have been my next question :roll:
It's all in the manual. What you want is this.ship.spawn("boulder", <number>);.
Smivs wrote:
The asteroid is a sub-entity, and I haven't been able to spawn anything as a death action from a sub-ent. Is this relevant?
Perhaps it is. I'm not sure whether a subentity can spawn something. Perhaps it can't. Alternatively you could make the main entity spawn the boulders. this.ship.owner.spawn("boulder", <number>);
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Boulders from asteroids question(s)

Post by Smivs »

I did try this the other way round, with the ship being a sub-ent of the asteroid, and found it couldn't spawn anything, so it seems that sub-ents can't spawn stuff.
I'll certainly try "this.ship.owner.spawn("boulder", <number>);" , although it might have to wait till the morning now.
I assume that goes in the sub-ents part of shipdata, yes?.
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: Boulders from asteroids question(s)

Post by Commander McLane »

Smivs wrote:
I did try this the other way round, with the ship being a sub-ent of the asteroid, and found it couldn't spawn anything, so it seems that sub-ents can't spawn stuff.
I'll certainly try "this.ship.owner.spawn("boulder", <number>);" , although it might have to wait till the morning now.
I assume that goes in the sub-ents part of shipdata, yes?.
It has nothing to do with the sub-ents part of the shipdata, not even with shipdata at all. It's a JS-script, only a tiny variation of your JS-script. You are only supposed to add 'owner.' and a comma plus a number (less than 64).
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5525
Joined: Thu Jun 12, 2008 6:55 pm

Re: Boulders from asteroids question(s)

Post by Thargoid »

Try replacing

Code: Select all

this.ship.spawn("boulder");
with

Code: Select all

system.addShips("boulder", 10, this.ship.position, 500);
That will add 10 boulders within 500m of the ships current position (or in this case the position it held when it died).

For exact details of what's done there, see the wiki.[/color]
User avatar
Smivs
Retired Assassin
Retired Assassin
Posts: 8408
Joined: Tue Feb 09, 2010 11:31 am
Location: Lost in space
Contact:

Re: Boulders from asteroids question(s)

Post by Smivs »

Thanks, both. I now have boulders, and am a happy fellow :D

You know I spent most of yesterday looking at various Wiki pages, and you still managed to find things I hadn't found. :oops:
Am I the only person who finds the js sections almost impossible to navigate? Is there an index page or something I've missed?
Last edited by Smivs on Mon Mar 07, 2011 9:28 am, edited 1 time in total.
Commander Smivs, the friendliest Gourd this side of Riedquat.
Post Reply