Scripting requests
Moderators: winston, another_commander
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
Cheers Ahruman, i'll give that a shot.
Thargoid, apart from my staggering ineptitude when it comes to javascript, i dunno if that would give the effect i want. the launch delay is logical etc (although i do think the stations should have some emergency rapid launch facility in case they got attacked), so i can live w/ it. the repeated launch loop, even w/ a few seconds delay, is enough to gradually swarm the attacker.
lol point in testing : i found out i'd forgotten to change my defense ship AI : it launched and just headed off happily toward the planet :-/
Thargoid, apart from my staggering ineptitude when it comes to javascript, i dunno if that would give the effect i want. the launch delay is logical etc (although i do think the stations should have some emergency rapid launch facility in case they got attacked), so i can live w/ it. the repeated launch loop, even w/ a few seconds delay, is enough to gradually swarm the attacker.
lol point in testing : i found out i'd forgotten to change my defense ship AI : it launched and just headed off happily toward the planet :-/
One thought - not sure if it's something desirable or feasible. We can do a lot of communicating between AIs and scripts now, but to do something on the player ship is awkward as there is no AI involved. Hence to do something like a safeScriptActionOnTarget a temporary entity would need to be spawned near the player, target them, do the command via its own AI and then be removed again.
As there are some nice tricks that can be done using sSAOT in relation ot the player ship, would a JS worldscript command which does something similar and accepts AI commands be possible?
For example something like playerShip.scriptAction("performTumble") to pick an arbitrary name for the function? Or is that mixing JS and AI too much? Just to be able to do things directly rather than the roundabout way.
As there are some nice tricks that can be done using sSAOT in relation ot the player ship, would a JS worldscript command which does something similar and accepts AI commands be possible?
For example something like playerShip.scriptAction("performTumble") to pick an arbitrary name for the function? Or is that mixing JS and AI too much? Just to be able to do things directly rather than the roundabout way.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
right, can't get Ahruman's script to work.
kicked it through, i got "[script.javaScript.warning.undefinedProp]: ----- JavaScript warning (newscript.js 1.0): reference to undefined property this.ship"
i tried replacingit w/ "this.station", as the wiki seemed to suggest that the "station" entity had the dockedDefenders" etc but "ship" doesn't, made no diff : "[script.javaScript.warning.undefinedProp]: ----- JavaScript warning (newscript.js 1.0): reference to undefined property this.station"
edit : tried to copy Random Hits and put in
"this.defenders = this.ship.dockedDefenders;"
and it says "reference to undefined property this.defenders"
well, didn't i just define it? >:-/
i wish we used BASIC rather than javascript, i was lush at that. BBC BASIC rocked!
kicked it through, i got "[script.javaScript.warning.undefinedProp]: ----- JavaScript warning (newscript.js 1.0): reference to undefined property this.ship"
i tried replacingit w/ "this.station", as the wiki seemed to suggest that the "station" entity had the dockedDefenders" etc but "ship" doesn't, made no diff : "[script.javaScript.warning.undefinedProp]: ----- JavaScript warning (newscript.js 1.0): reference to undefined property this.station"
edit : tried to copy Random Hits and put in
"this.defenders = this.ship.dockedDefenders;"
and it says "reference to undefined property this.defenders"
well, didn't i just define it? >:-/
i wish we used BASIC rather than javascript, i was lush at that. BBC BASIC rocked!
Have you assigned the script to the station?
In the shipdata.plist entry for the station you need a line script = "yourscripnamehere.js"; or it's XML equivalent, replacing of course yourscriptnamehere.js with the scripts name (newscript.js from your error post).
It needs to run as a ship script not a worldscript. By doing so this.ship gets defined (as the entity attached to the script, the station in this case).
In the shipdata.plist entry for the station you need a line script = "yourscripnamehere.js"; or it's XML equivalent, replacing of course yourscriptnamehere.js with the scripts name (newscript.js from your error post).
It needs to run as a ship script not a worldscript. By doing so this.ship gets defined (as the entity attached to the script, the station in this case).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
- Killer Wolf
- ---- E L I T E ----
- Posts: 2278
- Joined: Tue Jan 02, 2007 12:38 pm
If you can package it up somewhere and send me a suitable link I'll have a look at it for you when I get chance.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
Added shipAttackedOther(other) to trunk.Commander McLane wrote:I'd like to renew a scripting request that wasn't yet granted in 1.74:
A new event handler (world and ship scripts) as complement of shipBeingAttacked, which is sent to the attacked ship. The new handler should at the same time be sent to the attacker, with a parameter containing the entity that was hit. Should work for lasers and probably for plasma balls as well.
All times ship a attacks ship b, whether intentionally or not, ship b gets shipBeingAttacked(ship a) and ship a will get shipAttackedOther(ship b).
Should do what you need!
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- 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:
From some small works I've been doing for Killer Wolf from his request above, we've noticed some issues with the launch queue and defense ships. When a station is fired upon, it seems to take a horribly long time (up to a minute) between first shot hitting and defense ships being launched.
Would it be possible to have the defense ships "jump the queue" and get out more immediately when they are actually needed? In one or two cases I've seen them stuck behind a trader coming out, or in others they just take forever. Maybe a command to immediateLaunch <role> or equivalent for the specific commands for ships like defenseShips?
Would it be possible to have the defense ships "jump the queue" and get out more immediately when they are actually needed? In one or two cases I've seen them stuck behind a trader coming out, or in others they just take forever. Maybe a command to immediateLaunch <role> or equivalent for the specific commands for ships like defenseShips?
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:
Expose missile_load_time to JS, as a read/write Ship property. Reason: not being able to change the time interval for an existing ship strikes me as unflexible. As it seems now, the time determined in shipdata cannot be altered by script, and even Ship.fireMissile() will automatically wait for the predetermined time.
I would like more flexibility for the AI, which would allow an NPC to at least fire a full salvo in retaliation before it goes puff.
I would like more flexibility for the AI, which would allow an NPC to at least fire a full salvo in retaliation before it goes puff.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Not really needed. Don't define a missile_load_time and define zero missiles. With a script you can add a missile to the ship and than fire it. And to prevent the use of unlimited missiles, you can keep a counter in your ship script.Commander McLane wrote:Expose missile_load_time to JS, as a read/write Ship property. Reason: not being able to change the time interval for an existing ship strikes me as unflexible. As it seems now, the time determined in shipdata cannot be altered by script, and even Ship.fireMissile() will automatically wait for the predetermined time.
I would like more flexibility for the AI, which would allow an NPC to at least fire a full salvo in retaliation before it goes puff.
That is what I did with the astrominers in random_hits. They shoot pods in the form of missiles to the hopper for collecting it. But code dictated that 1 out of ten fired missiles is from the random set. By adding explicit missiles by script, I still keep control over what is shot and you even can make your own mix of fired missiles.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
missile_load_time has been exposed to JS in r3662. The JS property is called missileLoadTime, is read/write and has to be a positive number.Commander McLane wrote:Expose missile_load_time to JS, as a read/write Ship property. Reason: not being able to change the time interval for an existing ship strikes me as unflexible. As it seems now, the time determined in shipdata cannot be altered by script, and even Ship.fireMissile() will automatically wait for the predetermined time.
- 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: