cmdrmcdonald / EliteDangerousDataProvider

Apache License 2.0
134 stars 31 forks source link

Added scan values to body and star scanned events #274

Closed andre-arsenault closed 6 years ago

andre-arsenault commented 6 years ago

Assumes the ship has a Detailed Surface Scanner equipped. Does not include the 50% bonus for first discovery, as the "discovered by" information is not currently available in the journal events. Credit for the scan value formulae goes to MattG from this thread: https://forums.frontier.co.uk/showthread.php/232000-Exploration-value-formulae

Tkael commented 6 years ago
  1. Assuming a detailed surface scanner is present is not a good idea if you want to share this update with all users. We can't make the assumption that commanders will always have one installed. You can incorporate code to search the ship object for a detailed surface scanner, here's an example from an "Exploration Scanner Check" script that I use:
    
    {set discovery_scanner to 0}
    {set surface_scanner to 0}

{for compartment in ship.compartments: {if compartment.module.name = "Advanced Discovery Scanner": {set discovery_scanner to 3} |elif compartment.module.name = "Basic Discovery Scanner": {set discovery_scanner to 1} |elif compartment.module.name = "Detailed Surface Scanner": {set surface_scanner to 1} |elif compartment.module.name = "Intermediate Discovery Scanner": {set discovery_scanner to 2} } }

{SetState("discovery_scanner", discovery_scanner)} {SetState("surface_scanner", surface_scanner)}


2. In the case where a detailed surface scanner is not present, are there alternative calculations for body values without a detailed surface scanner? Or should the entire script be omitted if a detailed surface scanner isn't present?

Note: I've written a similar script for myself, but I use the information presented here: https://forums.frontier.co.uk/showthread.php/339546-2-3-exploration-payouts-visual-guide
Here's my version (making use of the "Exploration Scanner Script" that I already shared:

{ Exploration values are per https://forums.frontier.co.uk/showthread.php/339546-2-3-exploration-payouts-visual-guide } { Only values > 50,000 credits are included }

{_ Fetch from context } {set reportbody to BodyDetails(state.eddi_context_body_name, state.eddi_context_body_system)} {if !reportbody: {set reportbody to event} {set planettype to bodyclass} }

{if reportbody.type = "Body scanned"

|elif reportbody.type = "Star scanned" {if reportbody.stellarclass = "N":

}

}

{if state.discovery_scanner: {if state.surface_scanner: {set exploration_value to high} } |elif state.discoveryscanner: {if !state.surface_scanner: {set exploration_value to med} } |else: {set exploration_value to low} }

{if reportbody.planettype = "High metal content body" && reportbody.terraformstate = "Terraformable" : {if exploration_value = high: {set value to 412249} |elif exploration_value = med: {set value to 171770} } |elif reportbody.planettype = "Water world" && reportbody.terraformstate = "Terraformable" : {if exploration_value = high: {set value to 694971} |elif exploration_value = med: {set value to 289587} |elif exploration_value = low: {set value to 96524} } |elif reportbody.planettype = "Water world" && !reportbody.terraformstate = "Terraformable" : {if exploration_value = high: {set value to 301410} |elif exploration_value = med: {set value to 125587} } |elif reportbody.planettype = "Earthlike body": {if exploration_value = high: {set value to 627885} |elif exploration_value = med: {set value to 261619} } |elif reportbody.planettype = "Ammonia world": {if exploration_value = high: {set value to 320203} |elif exploration_value = med: {set value to 133418} } |elif reportbody.planettype = "Metal rich body": {if exploration_value = high: {set value to 65045} } |elif reportbody.planettype = "Rocky body" && reportbody.terraformstate = "Terraformable" : {if exploration_value = high: {set value to 181104} |elif exploration_value = med: {set value to 75460} } |elif reportbody.bodyclass= "Sudarsky class II gas giant": {if exploration_value = high: {set value to 53663} } |elif reportbody.stellarclass = "N": {if exploration_value = high: {set value to 54782} } |elif reportbody.stellarclass = "H": {if exploration_value = high: {set value to 60589} } }

{if value: Congratulations. That {OneOf("discovery", "scan", "{reportbody.terraformstate} {reportbody.planettype} {reportbody.bodytype}")} is {OneOf("typically", "usually")} worth {Humanise(value)} credits. }

andre-arsenault commented 6 years ago
  1. Good point, I knew this was a weakness but I didn't know how to check if a Detailed Surface Scanner was equipped. You provided that knowledge! I'll update my changes to resolve this.

  2. Yes, the difference in scan value without a DSS is a fixed multiplier. I always thought the DSS doubled the scan value, but after examining Redfox's visual guide a little closer it seems to be a 2.4x multiplier. So if the ship doesn't have a DSS equipped, I would divide the final scan value by 2.4. The type of Discovery Scanner (honk range) doesn't have an effect on scan value. I'll make this change as well.

Thanks for the feedback!

andre-arsenault commented 6 years ago

Changes made and tested to resolve both points.

Cheers!

Tkael commented 6 years ago

Ok. I still wasn't able to get your script to work for me and your script was using some programming techniques with which I am less familiar so I made my own variants:

{_ Calculated exploration values are per https://forums.frontier.co.uk/showthread.php/232000-Exploration-value-formulae & https://forums.frontier.co.uk/showthread.php/339546-2-3-exploration-payouts-visual-guide _}
{_ Only exploration values of > 50,000 credits are included _}

{_ Fetch from context }
{set reportbody to BodyDetails(state.eddi_context_body_name, state.eddi_context_body_system)}
{if !reportbody:
   {set reportbody to event}
   {set planettype to bodyclass}
}

{_ Check the state of the exploration scanners _}
{set shiphasdssequipped to:
    {for compartment in ship.compartments:
        {if compartment.module.name = "Detailed Surface Scanner":
            {return 1}
        }
    }
    {return 0}
}

{_ Calculate exploration values from constants and variables_}

{set bodydataconstant to 720}
{set terraconstant to 0}
{set body to cat(reportbody.planettype, reportbody.bodytype)}

{if find(reportbody.planettype, "Ammonia") >= 0:
   {set bodydataconstant to 232619}
|elif find(reportbody.planettype, "Earth") >= 0:
   {set bodydataconstant to 155581}
   {set terraconstant to 279088}
|elif find(reportbody.planettype, "Water world") >= 0:
   {set bodydataconstant to 155581}
   {set terraconstant to 279088}
|elif or(find(reportbody.planettype, "Metal rich") >= 0, find(reportbody.planettype, "Metal-rich") >= 0):
   {set bodydataconstant to 52292}
|elif find(reportbody.planettype, "High metal") >= 0:
   {set bodydataconstant to 23168}
   {set terraconstant to 241607}
|elif find(reportbody.planettype, "Rocky body") >= 0:
   {set terraconstant to 223971}
|elif find(reportbody.planettype, "Class I gas giant") >= 0:
   {set bodydataconstant to 3974}
|elif find(reportbody.planettype, "Class II gas giant") >= 0:
   {set bodydataconstant to 23168}
}
{if or(reportbody.terraformstate = "Terraformable", reportbody.terraformstate = "Candidate for terraforming", find(reportbody.planettype, "Earth") >= 0):
      {_ do nothing _}
|else:
      {set terraconstant to 0}
}

{_ Calculate exploration values _}
{set basevalue to (bodydataconstant + (3 * bodydataconstant * pow(reportbody.earthmass, 0.199977) / 5.3))}
{set terrabonusvalue to (terraconstant + (3 * terraconstant * pow(reportbody.earthmass, 0.199977) / 5.3))}
{if shiphasdssequipped: 
    {set calcvalue to basevalue + terrabonusvalue}
|elif !shiphasdssequipped: 
    {set calcvalue to ((basevalue + terrabonusvalue) / 2.4)}
}

{if calcvalue && calcvalue > 50000:
   {OneOf("Congratulations.", "Nice!")}
   {OneOf("this sensor reading", "this scan", "this sensor sweep", "that {body}")}
   is {OneOf("calculated", "estimated")}
   to be worth {Humanise(calcvalue)} credits.
}
{_ Calculated exploration values are per https://forums.frontier.co.uk/showthread.php/232000-Exploration-value-formulae & https://forums.frontier.co.uk/showthread.php/339546-2-3-exploration-payouts-visual-guide _}
{_ Only exploration values of > 50,000 credits are included _}

{_ Fetch from context }
{set reportbody to BodyDetails(state.eddi_context_star_star, state.eddi_context_star_system)}
{if !reportbody:
   {set reportbody to event)}
}

{_ Calculate exploration values from constants and variables_}

{set bodydataconstant to 2880}
{set body to cat(reportbody.stellarclass, "-class star", starname)}

{if reportbody.stellarclass = "H" || reportbody.stellarclass = "N":
    {_ Black holes and Neutron stars }
    {set bodydataconstant to 54309}
|elif match(reportbody.stellarclass, "^D[A-Z]?[A-Z]?$"):
    {_ White dwarfs }
    {set bodydataconstant to 33737}
}

{_ Calculate exploration values _}
{set calcvalue to (bodydataconstant + (reportbody.solarmass * bodydataconstant / 66.25))}

{if calcvalue && calcvalue > 50000:
   {OneOf("Congratulations.", "Nice!")}
    {if state.eddi_context_star_scanned = 1:
       This
       {OneOf("sensor reading", "scan", "sensor sweep")}
       {SetState('eddi_context_star_scanned', 0)}
    |else:
       {F("BodyName")}
    } 
   is {OneOf("calculated", "estimated")}
   to be worth {Humanise(calcvalue)} credits.
}
andre-arsenault commented 6 years ago

Sorry to hear it wasn't working for you. How did you try to use it? My change modified the built-in EDDI personality by adding two new events which were called from the existing "body scanned" and "star scanned" events (that way the user can disable them if they don't want to hear the scan values).

Tkael commented 6 years ago

Add this test code after you fetch from context: {set reportbody to BodyDetails("Earth", "Sol")} (Here are more systems that you can test: https://forums.frontier.co.uk/showthread.php/232000-Exploration-value-formulae?p=5470527&viewfull=1#post5470527)

This test code forces the script to use values from a known body and returns results using the "reportbody" function. It will report that a scan of Earth is worth just a little over 1,000 credits, which is incorrect. This result is, I think, due to the face that variables returned from the "reportbody" function do not always match those returned from the "event" variables. As examples, "Earth-like world" vs. "Earthlike body" and "Candidate for terraforming" vs. "Terraformable". In addition, "Earth-like" bodies should always include the "terraformable" bonus - I don't believe your calculations currently account for that and consequently you'll find that Earth-like bodies are always reported under their actual values.

andre-arsenault commented 6 years ago

Thanks once again for identifying some outliers and improving my testing method!

My most recent update includes the handling of the issues you identified, plus "Metal-rich body" (vs "Metal rich body") and "High metal content world" (vs "High metal content body).

andre-arsenault commented 6 years ago

Closing this pull request in favour of creating a new one in the https://github.com/EDCD/EDDI/ repo instead.