Page 97 of 99

Re: Scripters cove

Posted: Sat Oct 20, 2018 8:02 am
by Nite Owl
Thank you phkb for the explanation.

Much appreciation to all three of you for your help and guidance.

The gauge is now installed on my Coluber HUD and updating properly. This includes a nicely colored bar and a level measuring background image like those used on all of the other gauges in the Coluber HUD. Have even gotten to the point where most JavaScript Operators and other such stuff are becoming readable without too much consulting of reference material.

One step closer to the Dark Side. <Eats the cookies>

Re: Scripters cove

Posted: Sat Oct 20, 2018 8:05 am
by Norby
phkb wrote:
Sat Oct 20, 2018 1:05 am
it doessn't always make sense to display them
Currently serviceLevel is important only before you want to buy another ship: a maintenance can give better price for your ship.

Over this I attempted to make more sense in my hardcore addon named to ShipVersion, which penalized the player ship by losing all laser weapons when the serviceLevel reached the minimal value, like break off from the damaged hull.

But regardless of my repeated warnings that ShipVersion is designed only for top experienced players who want extra challenges, new players also regularly installed it, then complained about losing weapons "without any notice", so finally I removed this feature.

Re: Scripters cove

Posted: Sat Oct 20, 2018 8:06 am
by Norby
Nite Owl wrote:
Sat Oct 20, 2018 8:02 am
The gauge is now installed on my Coluber HUD and updating properly.
Nice work, congrats! :)

Re: Scripters cove

Posted: Sat Feb 02, 2019 5:24 am
by montana05
An interesting observation for laser weapons (excluding turrets) assigned to a subentity of a NPC ship:

When you assign a laser weapon as a subentity the common way (as much as I saw) is to define the laser as

Code: Select all

"forward_weapon_type" =
which makes sense, once the orientation is correct the front of the subentity should be the target area. Unfortunately the result is not exactly like that. If assigned to the back of the ship this lasers still work as front-lasers and not in the intended way.

Anybody else had a similar observation and are there any ideas how to work around this problem ?

PS:
Assigning the weapons to the ship as multiple lasers is obviously working, you even could keep the subentities as decoration. Problem is that this method doesn't offer different types.

Re: Scripters cove

Posted: Sun Feb 03, 2019 1:16 am
by montana05
While trying to find a work-around I ran into another problem, NPC ships hardly use back-weapons and even less broadsides. Is there any way that you could force or at least raise the chances that they are fired ?

Re: Scripters cove

Posted: Sun Feb 03, 2019 8:05 am
by another_commander
montana05 wrote:
Sun Feb 03, 2019 1:16 am
While trying to find a work-around I ran into another problem, NPC ships hardly use back-weapons and even less broadsides. Is there any way that you could force or at least raise the chances that they are fired ?
Yes there is. Increase their accuracy to above 5. Then the AI will start utilizing the more advanced tactics. Not entirely sure about it, but I don't think you can make it use side lasers for combat.

As for the forward_weapon_type subentities placed aft, have you tried using aft_weapon_type instead?

Re: Scripters cove

Posted: Sun Feb 03, 2019 9:15 am
by montana05
another_commander wrote:
Sun Feb 03, 2019 8:05 am
Yes there is. Increase their accuracy to above 5. Then the AI will start utilizing the more advanced tactics. Not entirely sure about it, but I don't think you can make it use side lasers for combat.
The various stages of accuracy I am using already, in this case I guessed 8.50 would be enough, well, I will try to get up to 10.00 to watch the results.
another_commander wrote:
Sun Feb 03, 2019 8:05 am
As for the forward_weapon_type subentities placed aft, have you tried using aft_weapon_type instead?
My first thought, would be be the most logic. Thats when I run into the second problem :D

Update:
The easiest way to force a NPC ship to use the rear-lasers for a test is to set the front-lasers to "NONE" :roll:
It seems that aft_weapon works as intended, the lasers fire at their own ship.

Conclusio for today, for now I will refrain from using subentities as rear-lasers, instead assigning them to the ship with the multi feature.

Re: Scripters cove

Posted: Mon Feb 04, 2019 6:37 am
by montana05
Another day, another surprise. It seems that self-aiming lasers (is_turret_laser = true;) ignore "weapon_mount_mode" = "multiply"; and/or "weapon_position_". All shots are fired from the center of the ship (0 0 0) so difficult to say if multi is recognized. Well, at least they fire now, once again not exactly as intended. :lol:

Re: Scripters cove

Posted: Mon Apr 08, 2019 11:36 am
by phkb
I know I should probably know this, but can someone remind me how you calculate the mass-lock distance of a sun or planet?

Re: Scripters cove

Posted: Mon Apr 08, 2019 12:50 pm
by another_commander
Here is the code from PlayerEntity.m:

Code: Select all

Entity<OOStellarBody> *stellar = (Entity<OOStellarBody> *)ent;
if (EXPECT([stellar planetType] != STELLAR_TYPE_MINIATURE))
{
	double dist = stellar->zero_distance;
	double rad = stellar->collision_radius;
	double factor = ([stellar isSun]) ? 2.0 : 4.0;
	// plus ensure mass lock when 25 km or less from the surface of small stellar bodies
	// dist is a square distance so it needs to be compared to (rad+25000) * (rad+25000)!
	if (dist < rad*rad*factor || dist < rad*rad + 50000*rad + 625000000 ) 
	{
		massLocked = YES;
	}
}

Re: Scripters cove

Posted: Mon Apr 08, 2019 9:45 pm
by phkb
Thanks, a_c! You know, I looked at that bit of code and somehow completely missing a crucial detail: "dist is a square distance". Note to self: must take more care when reading comments.

Re: Scripters cove

Posted: Sun May 05, 2019 12:32 pm
by montana05
I never saw it before and I never thought its possible until recently I was proofed wrong, thanks to a copy & past glitch. It is possible to assign a subentity to a subentity, for example a flasher to a gun. The catch is that the coordinates are the one from the main entity, same as with other certain assignments like forward_weapon = , external weapons assigned to the back of a ship will mainly shoot forward of the ship, not forward of the gun.

Re: Scripters cove

Posted: Thu May 30, 2019 10:59 pm
by UK_Eliter
Dear all

I am after a way of setting a (any) perpendicular course from a celestial object (sun or planet or secondary planet - or, better: a roughly - not exactly, i.e. I want some randomisation. I know how to get the celestial entity - with all its properties, I think - as an element in an array, but I don't know how to get a ship, which is controlled by plist AI + js ship script, to set the desired course away from the entity.

I think phkb might help me with this, but I have leaned on him a lot of already recently, and/but I don't really have the knowledge, or perhaps the mathematical background, to work it out myself. (I did look at relevant pages on the javascript and AI wikis, but I couldn't find anything suitable. I considered trying to use the plist AI method 'performFlee', but I am unsure I can set the flee-from-target to any celestial, as against a ship.)

Re: Scripters cove

Posted: Fri May 31, 2019 4:22 am
by phkb
Well, I'm here, so, you know... :wink:

This code will set the orientation of a ship to be away from the given planet (entity):

Code: Select all

// orient the ship so it is facing away from the entity
this.$orientationAwayFromEntity = function $orientationAwayFromEntity(ship, entity) {
    ship.orientation = entity.position.subtract(ship.position).direction().rotationTo([0,0,-1]);
}
Although if we're trying to get the AI to do something, it might be better to set a waypoint away from the planet and ask the AI to fly towards it:

Code: Select all

// returns a position that's the same distance as between the ship and the entity, but in the opposite direction 
this.$positionAwayFromEntity = function $positionAwayFromEntity(ship, entity) {
    return Vector3D.interpolate(ship.position, entity.position, -1);
}
No randomisation in that position, obviously, but I'll leave that for someone else. :)

Re: Scripters cove

Posted: Fri May 31, 2019 12:21 pm
by UK_Eliter
Thanks! I'll have a go with that code and with the ideas offered elsewhere by rustem.