Page 25 of 56

Posted: Tue Jun 29, 2010 6:51 am
by Killer Wolf
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 :-/

Posted: Wed Jun 30, 2010 5:15 pm
by Thargoid
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.

Posted: Wed Jun 30, 2010 6:08 pm
by Killer Wolf
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! :-D

Posted: Wed Jun 30, 2010 6:36 pm
by Thargoid
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).

Posted: Thu Jul 01, 2010 6:27 am
by Killer Wolf
aye, i've done that.
does the fact i spawn it up w/ it's own role rather than "station" make an impact?

Posted: Thu Jul 01, 2010 6:32 am
by Thargoid
No.

Posted: Thu Jul 01, 2010 9:08 am
by Killer Wolf
tch. oh well, back to the drawing board tonight!
i never thought about xml scripts, tbh, i'm assuming they might be easier to do that JS for a numpty like me, i'll have to see if there's owt on wiki that i can understand.

Posted: Thu Jul 01, 2010 11:06 am
by Thargoid
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.

Posted: Sat Jul 03, 2010 3:11 pm
by Kaks
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.
Added shipAttackedOther(other) to trunk.
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! :)

Posted: Sat Jul 03, 2010 3:58 pm
by Commander McLane
Thanks a lot! :D

Posted: Thu Jul 08, 2010 6:34 am
by Thargoid
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?

Posted: Fri Jul 09, 2010 10:10 am
by Commander McLane
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.

Posted: Fri Jul 09, 2010 11:28 am
by Eric Walch
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.
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.
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.

Posted: Fri Jul 09, 2010 12:25 pm
by another_commander
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.
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.

Posted: Fri Jul 09, 2010 12:54 pm
by Commander McLane
Great! :D