You got itCommander 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.
Scripting requests
Moderators: winston, another_commander
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
- Commander McLane
- ---- 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:
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.
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.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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.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?
In this case you must probably define an escape pod model that defines cargo_type = CARGO_SCRIPTED_ITEM
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- 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:
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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.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.
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]];
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- 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:
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.
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.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Commander McLane
- ---- 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:
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.
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.
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!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.
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
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 awayKaks 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!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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- 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:
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.Eric Walch wrote: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 awayKaks 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!
- Commander McLane
- ---- 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:
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:
The line
randomly returns one of the economic descriptions. What I would like is the possibility to return a specific description through an optional parameter. So
would return "Rich Industrial", and
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.
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"
);
Code: Select all
expandDescription("[economy]");
Code: Select all
expandDescription("[economy]", 0);
Code: Select all
expandDescription("[economy]", 7);
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.
- Commander McLane
- ---- 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:
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.
Last edited by Commander McLane on Wed Nov 04, 2009 9:47 am, edited 1 time in total.
- DaddyHoggy
- Intergalactic Spam Assassin
- Posts: 8515
- Joined: Tue Dec 05, 2006 9:43 pm
- Location: Newbury, UK
- Contact:
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.Commander McLane wrote:A reminder to something I requested a while back: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.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.
Oolite Life is now revealed hereSelezen wrote:Apparently I was having a DaddyHoggy moment.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
How about this Ahruman even provided a small script example.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.
UPS-Courier & DeepSpacePirates & others at the box and some older versions