Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Commander McLane
---- E L I T E ----
---- 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:

Re: Scripters cove

Post by Commander McLane »

Not sure whether equipment.plist supports this.

Anyway, if it does, the square brackets should contain the descriptions.plist key, just like in all other substitution cases.

Edit: a quick test shows that it doesn't seem to be supported.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

And even if it did work, there'd be no guarantee that the equipment would have a consistent name from one view to the next, since entries from descriptions.plist arrays are picked randomly each time.
User avatar
superbatprime
Dangerous
Dangerous
Posts: 120
Joined: Tue Oct 09, 2012 10:09 am
Location: Location, Location.

Re: Scripters cove

Post by superbatprime »

*sigh*
Thanks guys, sheesh I always want to do the thing that can't be done. :(
At least I've learned enough stuff to get this far.

Okay I'll change tactics.

What if I have all variations of the equipment listed in the equipment plist as separate entries, can I get Oolite to randomly display only one item from the list in the equipment market?

So it would be like this in the equipment plist.

Code: Select all

(
   (
      0,
      5000,
      "my item serial #001",
      "EQ_MY_ITEM",
      "mildly humorous description of the item",
       {
          "available_to_all" = YES;
		  "portable_between_ships" = yes;
       }
    )
)

(
   (
      0,
      5000,
      "my item serial #002",
      "EQ_MY_ITEM",
      "mildly humorous description of the item",
       {
          "available_to_all" = YES;
		  "portable_between_ships" = yes;
       }
    )
)
(I'm sure there are brackets to clean up there but you get the gist).

Can I then get the game to select one at random?
So then I says to him, I says "naw dude, Oolite ain't no Space Opera... Oolite is Space Rock and Roll!"
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post by cim »

If you give them TL:99, you can then set mission variables from script to set one, and only one, in each system - on shipWillExitWitchspace, probably - to have the real tech level. (In the next version you will be able to do this much more neatly with a "condition script", but this is the easiest way for now)

If you make them all incompatible with each other, that will make this a little easier, too.
User avatar
Commander McLane
---- E L I T E ----
---- 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:

Re: Scripters cove

Post by Commander McLane »

The currently best way of selecting which equipment gets offered is through its tech level. That's also the only way I can think of off the top of my head that'll allow you to make sure that every time one (and only one) of several similar items is offered.

First, all your items need a distinct identifier. There may not be two items EQ_MY_ITEM. Thus, you have to name them EQ_MY_ITEM_1, EQ_MY_ITEM_2, and so on.

Second, you have to give all your items a tech level of 99. This is a special tech level, which can be changed to any number you want on the fly (this is expressly not possible for any other tech level).

Then, you need to redefine it in your world script, based on a random selection. If you want a new random each time the player visits the F3-screen, guiScreenWillChange is the event you're looking for:

Code: Select all

this.guiScreenWillChange = function(to, from)
{
    if(!player.ship.docked) return; // a safety measure, because you could've been launched in the meantime
    if(to === "GUI_SCREEN_EQUIP_SHIP")
    {
        var choice = Math.ceil(Math.random() * 5) // replace with the number of items
        switch(choice)
        {
            case 1:
               EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = 0;    // item available
               EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null; // reset TL to 99, not available
               EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
               break;
               
            case 2:
               EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = 0;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
               break;
               
            case 3:
               EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = 0;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
               break;
               
            case 4:
               EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = 0;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null;
               break;
               
            case 5:
               EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null;
               EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = 0;
        }
    }
}
A shorter way, making use of JS's ability to transform your random choice number into a string, and manipulate strings directly, would be:

Code: Select all

this.guiScreenWillChange = function(to, from)
{
    if(!player.ship.docked) return; // a safety measure, because you could've been launched in the meantime
    if(to === "GUI_SCREEN_EQUIP_SHIP")
    {
        var choice = Math.ceil(Math.random() * 5) // replace with the number of items
        EquipmentInfo.infoForKey("EQ_MY_ITEM_1").effectiveTechLevel = null; // reset
        EquipmentInfo.infoForKey("EQ_MY_ITEM_2").effectiveTechLevel = null; // all
        EquipmentInfo.infoForKey("EQ_MY_ITEM_3").effectiveTechLevel = null; // items
        EquipmentInfo.infoForKey("EQ_MY_ITEM_4").effectiveTechLevel = null; // to
        EquipmentInfo.infoForKey("EQ_MY_ITEM_5").effectiveTechLevel = null; // TL 99
        EquipmentInfo.infoForKey("EQ_MY_ITEM_" + choice.toString()).effectiveTechLevel = 0; // set only one to 0
    }
}
"EQ_MY_ITEM_" + choice.toString() obviously resolves to EQ_MY_ITEM_1, EQ_MY_ITEM_2, EQ_MY_ITEM_3, EQ_MY_ITEM_4, or EQ_MY_ITEM_5.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

Another way is to set a condition in each piece of equipment requiring a mission variable to be a certain value or range of values if you wish some overlap (a different value for each item variant), and then use a script to pseudo-randomly set that variable to one of the values in the range of your equipment on start-up and witchspace exit.

That works in the current release version, and as Cim says will only get easier when 1.77 comes out.
User avatar
superbatprime
Dangerous
Dangerous
Posts: 120
Joined: Tue Oct 09, 2012 10:09 am
Location: Location, Location.

Re: Scripters cove

Post by superbatprime »

Gentlemen thank you, that is doing what it should be doing now and more importantly I understand how it's doing it. :)
So then I says to him, I says "naw dude, Oolite ain't no Space Opera... Oolite is Space Rock and Roll!"
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

If you want an example, look into the mission equipment in Aquatics.
User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

Is it possible to display all for weapon temperatures at once? I've a HUD design in mind incorporating all four in a cross-display with the number for the view displayed next to the temperature, as well as a few more concepts to integrate that I may need help with in the future.
Got all turned around, lost my nav connection... Where am I now?
User avatar
Commander McLane
---- E L I T E ----
---- 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:

Re: Scripters cove

Post by Commander McLane »

Rese249er wrote:
Is it possible to display all for weapon temperatures at once?
I don't think so.
User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

*snaps fingers* Back to the drawing board.
Got all turned around, lost my nav connection... Where am I now?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2457
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripters cove

Post by Wildeblood »

An arithmetic question. I need a procedure that will take a number between 0 and 36000 (actually 4000 to 40000, but I think I can manage adding and subtracting 4000) and output a number between 0 and 3996000 (4000000-4000), such that there's no distortion at the bottom of the range, but a 100x exaggeration at the top of the range. So 4000 -> 4000, but 40000 -> 4000000, or 0 -> 0, but 36000 -> 3996000. I think this is called a geometric progression, but being the victim of a state school education, my mathematical ability is limited to basic addition and subtraction.
User avatar
spara
---- E L I T E ----
---- E L I T E ----
Posts: 2691
Joined: Wed Aug 15, 2012 4:19 am
Location: Finland

Re: Scripters cove

Post by spara »

Wildeblood wrote:
An arithmetic question. I need a procedure that will take a number between 0 and 36000 (actually 4000 to 40000, but I think I can manage adding and subtracting 4000) and output a number between 0 and 3996000 (4000000-4000), such that there's no distortion at the bottom of the range, but a 100x exaggeration at the top of the range. So 4000 -> 4000, but 40000 -> 4000000, or 0 -> 0, but 36000 -> 3996000. I think this is called a geometric progression, but being the victim of a state school education, my mathematical ability is limited to basic addition and subtraction.
Is this what you are looking for: f(x)=x*100^((x-4000)/36000), where 4000 <= x <= 40000 ?
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2457
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Scripters cove

Post by Wildeblood »

spara wrote:
Is this what you are looking for: f(x)=x*100^((x-4000)/36000), where 4000 <= x <= 40000 ?
I think it is. Thank you.
:( :evil:
Last edited by Wildeblood on Tue Dec 04, 2012 9:02 am, edited 1 time in total.
User avatar
Rese249er
---- E L I T E ----
---- E L I T E ----
Posts: 647
Joined: Thu Jun 07, 2012 2:19 pm
Location: Well, I WAS in G3...

Re: Scripters cove

Post by Rese249er »

Through experimenting with a hud.plist for the next version of HoloNumHUD, I discovered that only one scanner will be drawn at a time. Is it feasible to remove this restriction? I've an idea that a separate scanner of zero height could be drawn over the crosshairs to aid aiming by 'instruments' in addition to the typical scanner (or a square-boundary scanner.)
Got all turned around, lost my nav connection... Where am I now?
Post Reply