Page 20 of 56

Posted: Fri Oct 23, 2009 7:19 am
by another_commander
Commander McLane wrote:
A new event handler shipFiredMissile(missile,target), sent to the firing ship, both player and NPC. Should return the missile entity and the target the missile was fired at.
You got it ;-)

Posted: Sat Oct 24, 2009 12:21 pm
by Commander McLane
A method for the player ship to send distress messages.

Doesn't necessarily mean that he has to send out a comms message, but what I want is a way to make police and hunters detect an attack on the player, like they do detect an attack on clean NPCs.

According to my test there is currently an ACCEPT_DISTRESS_CALL message sent to police and hunters, if a clean NPC is attacked in their vicinity. No such thing if the victim is the player. So police and hunters generally don't come to his rescue, except by finding his attackers through their usual scanForOffenders eventually. But this may take unlimited time, and doesn't work at all for hunters.

Therefore a property in PlayerShip would be nice, which can be set to true or false in order to determine whether police and hunters should come to his rescue as well. Or, if we just want single distress calls in special cases, a method to send one call.

Posted: Sat Oct 24, 2009 12:41 pm
by Eric Walch
Commander McLane wrote:
Following my trials and tribulations up to here, I'd like to know: Is there a good reason that the shipWasScooped and shipScoopedOther handlers do not fire if the scooped entity is an escape pod?
It does trigger for escape pods. However, it only triggers for scripted cargo. This was already so in 1.65. So you must define cargo_type = CARGO_SCRIPTED_ITEM. Only than it executes legacy script_actions or sends the handlers. This info was present on the page with these handlers.

In this case you must probably define an escape pod model that defines cargo_type = CARGO_SCRIPTED_ITEM

Posted: Sat Oct 24, 2009 1:01 pm
by Commander McLane
Yes, I know that.

My request is that it triggers also when cargo is not CARGO_SCRIPTED_ITEM.

Posted: Sun Oct 25, 2009 4:54 pm
by Eric Walch
Commander McLane wrote:
A way to clear a ship's target via JS. (Or tell me how it is done, I can't figure it out.)

this.ship.target = null doesn't do anything and is reported as an error, same for this.ship.target = "". I guess that is because it actually points to another ship, which can't be nullified.

Therefore another way to reset the target of an NPC (or even the player) is needed. Probably a method.

It should trigger the "TARGET_LOST" message in the AI.
This not working is an Oolite bug. Adding a target with JS is handled as - (void) setTargetForScript:(ShipEntity *)target in "EntityOOJavaScriptExtension.m" . There is an explicit check to remove the target when the transferred target is nil. So it was always the intention to handle this.
However, the property that calls this function does first an integrity check to see if the target is a ship. Therefor a nil parameter is never transferred. I changed the code into letting this property accepting a nil parameter. But this still gives the error. Probably earlier in the code there is another check that forbids a nil parameter. (In missionVariable a null is allowed to clear it)

Setting itself as target also does nothing. I added a hack to the code that when setting itself as target, the target is also lost:

Code: Select all

	if (target != nil && target != me)  [me addTarget:target];
	else  [me removeTarget:[me primaryTarget]];
This works and even generates the TARGET_LOST message. I am just interested if this is an acceptable method to loose the target?

Posted: Fri Oct 30, 2009 5:56 am
by Commander McLane
A complementary event handler to shipBeingAttacked, sent to the ship that fired the laser. Could have the "victim" as (whom) parameter.

Posted: Fri Oct 30, 2009 7:23 am
by Thargoid
Can we have a new function under Clock to add a given amount of time to the clock? (Clock.addTime() or something like that)?

I was thinking of an additional "punishment" available instead of just fining credits. Now more relevant as we have all the reputation and delivery/long distance cargo options available, to make it more relevant to lose time along the way by being thrown in jail for a period of time, or otherwise delayed.

Posted: Mon Nov 02, 2009 3:20 pm
by Commander McLane
Move awardEquipment() from PlayerShip to Ship. Possible?

Or, perhaps even better: expose the has_foo shipdata-keys to JS, as read/write properties. Include missiles as well.

What I want is to be able to change an NPC's equipment on the fly, for instance give it a cloaking device (or take it away again). Currently that is not possible, because the only place to give equipment to NPCs is the shipdata, so if the ship is spawned, no changes are possible anymore.

Posted: Mon Nov 02, 2009 3:48 pm
by Kaks
Commander McLane wrote:
Move awardEquipment() from PlayerShip to Ship. Possible?

Or, perhaps even better: expose the has_foo shipdata-keys to JS, as read/write properties. Include missiles as well.
All that should be in trunk already. I'll need to double check if things work ok when assigning missiles, though. Something to keep me busy this evening! :)

Posted: Mon Nov 02, 2009 5:04 pm
by Eric Walch
Kaks wrote:
Commander McLane wrote:
Move awardEquipment() from PlayerShip to Ship. Possible?

Or, perhaps even better: expose the has_foo shipdata-keys to JS, as read/write properties. Include missiles as well.
All that should be in trunk already. I'll need to double check if things work ok when assigning missiles, though. Something to keep me busy this evening! :)
Not yet, only hasEquipment() but now awardEquipment() I just tried a few days back to remove equipment by script for a griff-krait when the corresponding subentity was shot away :P

Posted: Tue Nov 03, 2009 5:44 am
by Commander McLane
Eric Walch wrote:
Kaks wrote:
All that should be in trunk already. I'll need to double check if things work ok when assigning missiles, though. Something to keep me busy this evening! :)
Not yet, only hasEquipment() but now awardEquipment() I just tried a few days back to remove equipment by script for a griff-krait when the corresponding subentity was shot away :P
And I actually would prefer my second request: having hasECM, hasEscapePod, etc. as r/w properties, instead of the award/removeEquipment() methods. But if those are easier to implement (and somehow through hasEquipment() the road is already paved), I am also fine with that.

Posted: Tue Nov 03, 2009 11:39 am
by Commander McLane
As per this problem of mine, is it possible to add an optional parameter to expandDescription(), that would allow to extract a specific string out of an array in descriptions.plist?

Example: In Oolite's own descripions.plist there is the array with the economy strings:

Code: Select all

    economy = (
        "Rich Industrial", 
        "Average Industrial", 
        "Poor Industrial", 
        "Mainly Industrial", 
        "Mainly Agricultural", 
        "Rich Agricultural", 
        "Average Agricultural", 
        "Poor Agricultural"
    ); 
The line

Code: Select all

     expandDescription("[economy]");
randomly returns one of the economic descriptions. What I would like is the possibility to return a specific description through an optional parameter. So

Code: Select all

     expandDescription("[economy]", 0);
would return "Rich Industrial", and

Code: Select all

     expandDescription("[economy]", 7);
would return "Poor Agricultural".

Would that even be possible? It would be helpful in order to automatically extract parts of descriptions.plist and write them into a JS array.

Posted: Wed Nov 04, 2009 6:27 am
by Commander McLane
A reminder to something I requested a while back:

Oops! Completely forgot that this will come in 1.74. Thanks, Eric, for reminding me. And thanks, Ahruman, for implementing it for my benefit! :)

So there is only the other thing I requested back then: Can player.ship.galaxyCoordinates be made writable in connection with player.ship.scriptedMisjump? The result would be that the script could determine where the player ends up in interstellar space. Or, if this is too much freedom, could we instead get another property with a value from [0..1], which determines where along the way to his destination system the player falls out of his wormhole. What I'm requesting is a situation like described in Status Quo, where our heroes jump to Rafe Zetter's Anaconda, which is located not halfway between two systems, but at one tenth of the distance.

Posted: Wed Nov 04, 2009 8:40 am
by DaddyHoggy
Commander McLane wrote:
A reminder to something I requested a while back:
Commander McLane wrote:
A system-property that contains all systems in jumprange, depending on the player's current fuel, perhaps in an array. So if(system.systemsInRange.length == 0), we know that the player is stuck. (Of course it would have to work in interstellar space as well.) The engine already does the calculation when 'H' is pressed, or when an NPC performs performHyperSpaceExit, I only don't know how difficult it is to make it available to JS.
And the other thing I requested back then: Can player.ship.galaxyCoordinates be made writable in connection with player.ship.scriptedMisjump? The result would be that the script could determine where the player ends up in interstellar space. Or, if this is too much freedom, could we instead get another property with a value from [0..1], which determines where along the way to his destination system the player falls out of his wormhole. What I'm requesting is a situation like described in Status Quo, where our heroes jump to Rafe Zetter's Anaconda, which is located not halfway between two systems, but at one tenth of the distance.
It happened in Dark Wheel too I see to recall - the ship made a jump 0.2ly jump into deep space, to meet up with the chap (name evades me) who was playing host to some spider eggs.

Posted: Wed Nov 04, 2009 8:50 am
by Eric Walch
Commander McLane wrote:
A reminder to something I requested a while back:
Commander McLane wrote:
A system-property that contains all systems in jumprange, depending on the player's current fuel, perhaps in an array. So if(system.systemsInRange.length == 0), we know that the player is stuck. (Of course it would have to work in interstellar space as well.) The engine already does the calculation when 'H' is pressed, or when an NPC performs performHyperSpaceExit, I only don't know how difficult it is to make it available to JS.
How about this Ahruman even provided a small script example.