Page 5 of 56

Posted: Sun Oct 21, 2007 4:29 pm
by Arexack_Heretic
can entries in a descriptive-string-array be specifically called?

for example;

descriptions.plist:

Code: Select all

...
<key>shipname</key>
<array>
<string>Adder</string>
<string>Anaconda</string>
<string>Asp MkII</string>
...
string : [shipname$$2] == Asp MkII

As discussed in the random bounties and murders thread, we need a way to reliably save and recall values used to describe the marks.
The most reliable way as far as I can see is rolling the dice once and directly save the randomised values in variables.
Then use these variables to create the mark descriptions as well as their shipentities.

Would using myList = shipname() work?
with: mylist[2] == Asp MkII

Posted: Sun Oct 21, 2007 7:34 pm
by JensAyton
Arexack_Heretic wrote:
can entries in a descriptive-string-array be specifically called?
No.
As discussed in the random bounties and murders thread, we need a way to reliably save and recall values used to describe the marks.
JavaScript will be the way here… although I’m not sure precisely how at this point. Generating a set of randomized descriptions is no problem, the question is how to associate them with a particular ship. For this type of thing, it might be useful to be able to summon a ship with a specialized ship script, but then what would happen if the ship also had a script (or actions) specified in its shipdata.plist entry?

Come to think of it, it might be useful if ships with no script specified got a blank JS script, which could then be modified by other scripts. For instance, your generate-a-target script would do something like:

Code: Select all

let targetShip = system.addShip( ... )
let targetScript = targetShip.script
targetScript.randomAssassins_descriptions = this.generateDescriptions()
if (targetScript.didBecomeDead != undefined)
{
    targetScript.randomAssassins_oldDidBecomeDead = targetScript.didBecomeDead
}
targetScript.didBecomeDead = function(whom, why)
{
    if (whom == player)
    {
        player.commsMessage("Congratulations, you killed " + this.randomAssassins_descriptions.characterName + "! The bounty of " + this.randomAssassins_descriptions.bounty + " credits has been paid.")
        player.credits += this.randomAssassins_descriptions.bounty
    }
    
    worldScripts["random-assassins"].noteContractCompleted()
    
    // Call original didBecomeDead, if any
    if (this.randomAssassins_oldDidBecomeDead != undefined)
    {
        this.randomAssassins_oldDidBecomeDead(whom, why)
    }
}
What’s happening here is that the generated target ship’s script is being patched to do things related to your mission. In principle, any number of patches could be applied this way (as long as each one saves its functions with a unique name, thus the randomAssassins_ prefix).

However, this script snippet relies on the new system.addShip() function, which will return the newly generated ship so you can do stuff with it. I started work on this a while back, but it turned out to have complications, and probably won’t be in 1.70. :-/

Posted: Sun Oct 21, 2007 11:09 pm
by nijineko
can a speed limit be added? more specifically, some method for checking to see if a player entity is moving above a certain speed, and then after an amount of time start dropping the speed down until the ship is under it's own control again.

this request is split off from my commentary about getting shot off from a destroyed dockable at freakishly high speed, such that 30-60 mins of constant thrust does not appreciably alter ones course or speed. i don't mind being left a long distance away from the planet, i just want to be able to stop.

actually, let me rephrase this. i was able to successfully warp to another system. and was promptly slingshot away from the witchpoint at the same high speed. i had enough extra fuel tanks that i could warp several times, but i was left at high speed such that i could not do anything.

i would like to request that the game check the speed of player entities warping in and set that speed to the standard post-warp speed.

Posted: Mon Oct 22, 2007 12:40 pm
by Arexack_Heretic
That sounds more like a bug, Neko.
AFAIK speed should be reset to 30% or so after didExitWitchspace.

Also I thought speed already dropped off to max_speed after a while....depending on thrust and mass. But that may just be gamer-expectation. ;)

If your speed is above max, you should be able to decelerate.
Because of the non-newtonian physics in the game, I think however that it might be more logical if a max_speed*a_superaccelerated_factor should never be exceeded by any object.
(all entities limited to a max_speed ceiling independent of their assigned max_speed+evt boosters. say an absolute max_speed of 100.)

------------------------------

@ahruman:
About that last sentence...
Does that new this.addship() method if executed by a ship-entity remove it and then replace it by the designated ship-key?

Or did you mean 'ships added by this method can be fiddled with'?

---

Yeah you hit the main obstacle on the head there, using JS was always assumed to be inevitable.
Random descriptions have never been a problem, rather reproducing the same descriptions is.

This moldable ship.script thing is a nice idea.


--

I was hoping to use a set of standard, but customizable shipdata, using some of the pre-generated "missionVariable.mark_1_somevalue"s to modulate the parameters of the shipdata.
eg
<key>max_speed</key> <integer>30*[missionVariable.mark_1_maxspeedFactor]</integer>

Probably using seednumbers instead of missionVariables is neater, but the latter are easier to interpret and mess with for casual coders.

---

Are you sure converting plist.arrays into lists cannot be done by JS?

--

Posted: Mon Oct 22, 2007 1:19 pm
by JensAyton
Arexack_Heretic wrote:
That sounds more like a bug, Neko.
AFAIK speed should be reset to 30% or so after didExitWitchspace.

Also I thought speed already dropped off to max_speed after a while....depending on thrust and mass. But that may just be gamer-expectation. ;)

If your speed is above max, you should be able to decelerate.
Because of the non-newtonian physics in the game, I think however that it might be more logical if a max_speed*a_superaccelerated_factor should never be exceeded by any object.
(all entities limited to a max_speed ceiling independent of their assigned max_speed+evt boosters. say an absolute max_speed of 100.)
It’s possible that the speed is becoming “not a number” or “infinity”, in which case multiplication by it doesn’t do anything useful.
Arexack_Heretic wrote:
About that last sentence...
Does that new this.addship() method if executed by a ship-entity remove it and then replace it by the designated ship-key?

Or did you mean 'ships added by this method can be fiddled with'?
All ships can be fiddled with. The problem is that the legacy_addShips() family of functions don’t give you a reference to the ships they create.

Arexack_Heretic wrote:
I was hoping to use a set of standard, but customizable shipdata, using some of the pre-generated "missionVariable.mark_1_somevalue"s to modulate the parameters of the shipdata.
eg
<key>max_speed</key> <integer>30*[missionVariable.mark_1_maxspeedFactor]</integer>

Probably using seednumbers instead of missionVariables is neater, but the latter are easier to interpret and mess with for casual coders.
Not gonna happen.
Arexack_Heretic wrote:
Are you sure converting plist.arrays into lists cannot be done by JS?
On the contrary, it’s already done. But exposing, say, all of shipdata.plist to scripts would tie us down to implementation details. For instance, spawning ships is ridiculously expensive at the moment. I intend at some point to change the way ship types are represented internally, and have Oolite convert the shipdata.plist files into a different representation (which will be cached). Having to redo this whenever a script fiddles with the plist would make the entire exercise pointless.

Posted: Mon Oct 22, 2007 1:46 pm
by Arexack_Heretic
Arexack_Heretic wrote:
I was hoping to use a set of standard, but customizable shipdata, using some of the pre-generated "missionVariable.mark_1_somevalue"s to modulate the parameters of the shipdata.
eg
<key>max_speed</key> <integer>30*[missionVariable.mark_1_maxspeedFactor]</integer>

Probably using seednumbers instead of missionVariables is neater, but the latter are easier to interpret and mess with for casual coders.
Not gonna happen.
Why not?
Um.oh.
Arexack_Heretic wrote:
Are you sure converting plist.arrays into lists cannot be done by JS?
On the contrary, it’s already done. But exposing, say, all of shipdata.plist to scripts would tie us down to implementation details. For instance, spawning ships is ridiculously expensive at the moment. I intend at some point to change the way ship types are represented internally, and have Oolite convert the shipdata.plist files into a different representation (which will be cached). Having to redo this whenever a script fiddles with the plist would make the entire exercise pointless.
So...given that editing shipdatavalues by script is not a wise idea.
(if possible)
How then does this returned shipdata work?
I assume we will be able to specify in it's shipdata-setup_script (or whatever script will be most effective) that the properties of spawned ENTITY are of the scripted value.

About the lists: I intended to use this mechanism only to reliably reproduce the randomly generated descriptions and add corresponding ship-entities as demanded by the 'descriptions'.
If I know that
(missionVariable/seed=1) == shiplist[1](second entry in key-shiplist-array of descriptions.plist) == 'description string a' == 'wanted Asp II',
then I can do addShips: wanted Asp MkII.

Modifying the ship.properties are a different matter, but should be subject to the same scripted values.

What would be the best way?

spawn a shipentity, alter ship-properties by script during setup.
-can ship-model be altered at this point?
It would be a problem if the entity is already created.

for example:
-have a shipdata.plist with standardship copies piloted by mark1, mark2 etc,
-can a scripted pilot be altered (or alternatively replaced/added) at this point?
Getting the pilot to match the mark-description is as critical as getting the shiptype correct.

Posted: Mon Oct 22, 2007 2:45 pm
by JensAyton
Arexack_Heretic wrote:
So...given that editing shipdatavalues by script is not a wise idea.
(if possible)
How then does this returned shipdata work?
Ah.

system.addShip() will not return a shipdata.plist entry. It will return an individual Ship entity. You can then modify attributes of the ship (including its name and script) without affecting other ships of the same type. Equivalently, addShips() will return an array of Ship entities.

Posted: Mon Oct 22, 2007 2:54 pm
by Arexack_Heretic
I thought so.
great.

...just because now I'm curious, if the legacy-addShip does not generate a ship-entity, what does it do? The ship entities are there...or are they not real objects?

Posted: Mon Oct 22, 2007 3:29 pm
by JensAyton
Arexack_Heretic wrote:
I thought so.
great.

...just because now I'm curious, if the legacy-addShip does not generate a ship-entity, what does it do? The ship entities are there...or are they not real objects?
It generates ship entities, it just doesn’t provide them to the calling script for poking at. You could get a reference by searching through all the entities in the system… or, more usefully, having the new ships’ ship scripts call a method in your world script saying “hey, I’m here”.

Posted: Tue Oct 23, 2007 8:58 pm
by Arexack_Heretic
Are all entity-properties still read-only (as documented in the wiki) or can they already be changed in 1.69.1 JS?
(I know you said they would probably all be accesible in 1.7, how is that progressing?)

for example:
How would you go about changing the ship.model in JS?

(this would be required in order to prevent the neccesity of a shipdata that is number of marks*number of possible ships in size. there are 30 default ships)

Posted: Tue Oct 23, 2007 11:07 pm
by JensAyton
Arexack_Heretic wrote:
Are all entity-properties still read-only (as documented in the wiki) or can they already be changed in 1.69.1 JS?
(I know you said they would probably all be accesible in 1.7, how is that progressing?)
“Accessible” does not mean “editable”. And I don’t think I said “all”.
for example:
How would you go about changing the ship.model in JS?
You wouldn’t.
(this would be required in order to prevent the neccesity of a shipdata that is number of marks*number of possible ships in size. there are 30 default ships)
No it wouldn’t. You need one ship for each type that a mark could have. You can then modify, for instance, the shipDescription of the spawned ship to reflect the name of the mark, and set attributes on the ship so its script would know what to say when it’s killed.

Once the new addShips() family works, it should be possible to implement the victim ships without any new ship types, by spawning a random trader and patching its script. Using the legacy_addShips() family, it’s necessary to have a custom ship script that will identify the new ship to the mission script.

Posted: Tue Oct 23, 2007 11:13 pm
by Arexack_Heretic
oaky, maybe the ships in "list of possible_ships" can have roles for all marks...
whether a mark is already in system would then be detected according to primary_role

Posted: Wed Oct 24, 2007 6:23 am
by JensAyton
Arexack_Heretic wrote:
oaky, maybe the ships in "list of possible_ships" can have roles for all marks...
whether a mark is already in system would then be detected according to primary_role
Nah. When the ship spawns, its ship script tells the mission script that it exists. The mission script then stuffs it in a variable, and (if needed) checks if the mark still exists with isValid.

World script:

Code: Select all

this.mark = null
this.registerMark = function(ship)
{
    this.mark = ship
}


this.getMark = function()
{
    if (this.mark && !this.mark.isValid)
    {
        this.mark = null
    }
    return null
}
Ship script:

Code: Select all

this.didSpawn = function()
{
    worldScripts["ah-random-marks"]. ah_marks_registerMark(this.ship)
}
There are more details regarding dealing with wormholes and multiple ships, but I’ve got to go to work now. :-)

Posted: Wed Oct 24, 2007 9:58 am
by LittleBear
On Storing the variables, I've got this working OK:-

With:-

Code: Select all

<string>set: mission_random_hits_assassination_board_poster_title [assassination_board_poster_title]</string>
               <string>set: mission_random_hits_assassination_board_job_name [assassination_board_job_name]</string>
               <string>set: mission_random_hits_assassination_board_poster_name [assassination_board_poster_name]</string>
               <string>set: mission_random_hits_assassination_board_poster_system [assassination_board_poster_system]</string>
               <string>set: mission_random_hits_assassination_board_subject [assassination_board_subject]</string>
               <string>set: mission_random_hits_assassination_board_address1 [assassination_board_address1]</string>
               <string>set: mission_random_hits_assassination_board_address2 [assassination_board_address2]</string>
               <string>set: mission_random_hits_assassination_board_part1 [assassination_board_part1]</string>
               <string>set: mission_random_hits_mark_first_name [mark_first_name]</string>
               <string>set: mission_random_hits_mark_nick_name [mark_nick_name]</string>
               <string>set: mission_random_hits_mark_second_name [mark_second_name]</string>
               <string>set: mission_random_hits_mark_race_part1 [mark_race_part1]</string>
               <string>set: mission_random_hits_mark_race_part2 [mark_race_part2]</string>
               <string>set: mission_random_hits_assassination_board_part2 [assassination_board_part2]</string>
               <string>set: mission_random_hits_assassination_board_part3 [assassination_board_part3]</string>
               <string>set: mission_random_hits_mark_ship_description [mark_ship_description]</string>
               <string>set: mission_random_hits_mark_ship [level_one_mark_ship]</string>
               <string>set: mission_random_hits_assassination_board_part4 [assassination_board_part4]</string>
               <string>set: mission_random_hits_mark_system [mark_system_g1]</string>
               <string>set: mission_random_hits_assassination_board_part5 [assassination_board_part5]</string>
               <string>set: mission_random_hits_mark_fee [level_one_mark_fee]</string>
               <string>set: mission_random_hits_assassination_board_part6 [assassination_board_part6]</string>
               <string>set: mission_random_hits_mark_gender [mark_gender]</string>
               <string>set: mission_random_hits_assassination_board_part7 [assassination_board_part7]</string>
This works and the randomly generated description is stored in the mission varirables.

I'm hoping a:-

Code: Select all

planet_number equal [mission_random_hits_planetnumber]
galaxy_number equal [ mission_random_hits_galaxynumber]
mission_random_hits_status equal CONTRACT ACCEPTED
do set_mission_random_hits_add_mark YES
[code]

Then a

[code]
mission_random_hits_add_mark equal YES
mission_random_hits_mark_ship equal Cobra Mk III
do
addSystemShips : mark_cobra_mkIII 1
like_ship will take a bit of a battering as each type of ship a mark could be in would get a custom role.

Posted: Wed Oct 24, 2007 10:51 am
by Arexack_Heretic
your intended system is a bit different from mine L_B.

I intend the galcoop wanted-list to be non-contract so no need to accept a mission, the thugs will always be there (somewhere in the system).
and reset at intervals or when killed.
(note to self: change wanted-status to "Terminated/In Custody", cleardata at witchjump)
Your script is mission-directed and adds the marks only at the specified planet and only when the contract is accepted.

:) I'll be the lawr and you be the bandit. ;)


But the basic system of adding marks and specifying their particulars will likely use the same mechanisms.