Giter Site home page Giter Site logo

antennarange's Introduction

AntennaRange

A KSP mod that enforces and encourages the use of the bigger antennas.

For Part Developers

The Fields

AntennaRange extends and augments the functionality of the stock ModuleDataTransmitter through the new ModuleLimitedDataTransmitter class. This class uses four additional configurable fields to define the part's behavior.

nominalRange is the range, in meters, at which the part should function identically to the stock module, i.e. without any modification to the power cost or packet size. This is used along with maxPowerFactor to calculate the maximum range of the part.
simpleRange is the same as nominalRange, but is used when the mod is in "simple" mode. In general it will probably need to be a much larger number than nominalRange.
maxPowerFactor effectively sets the maximum range of the antenna by essentially capping how much the power may be "turned up" to get better range. I originally used 8 for this number, because it felt right. I've since used 4 (for my DTS) and 16 (for my Comm. 88-88). You don't want this number to be too high, or small probes will go uncontrollable a lot when transmitting.
maxDataFactor defines the maximum "speed up" bonus that comes from using antennas at less their nominal range. I originally used 4 for this number for all parts; the DTS has a higher bonus now.

Note that all of the fields needed for Squad's ModuleDataTransmitter still need to be filled out. Depending on how you're defining your parts, they might need to go in your AntennaRange patch, or they might already be defined on the base part.

The Mechanic

In general, the scaling functions assume the relation D² α P/R, where D is the total transmission distance, P is the transmission power, and R is the data rate. Data rate increases as range decreases below nominalRange: R α nominalRange² / D². By default, power use increases as range increases above nominalRange: P α D² / nominalRange². Optionally, power use may remain fixed, and data rate instead decreases as range increases above nominalRange: R α nominalRange² / D².

Patch Conventions

To maximize cross-compatibility, please consider the following conventions for ModuleManager patches regarding AntennaRange:

When providing new definitions for your own parts, always specify a :FOR[YourModHere] pass name. Whenever changing default AntennaRange definitions (e.g. if you were going to rebalance my antennas to suit your mod), please do so in the :AFTER[AntennaRange] pass. I recommend providing all optional functionality (e.g. enabling RemoteTech vs. AntennaRange modules) in separate patches using :NEEDS[] blocks.

A sample AntennaRange configuration for an all-new mod part might look like this:

@PART[modPartName]:FOR[YourModName]:NEEDS[AntennaRange,!RemoteTech]
{
	MODULE
	{
		// ### Module Definition ###
		name = ModuleLimitedDataTransmitter
		
		// ### Squad Definitions ###
		// Delay between transmission packets, in seconds
		packetInterval = 0.10
		
		// Data capacity of nominal transmission packets, in MiT
		packetSize = 2
		
		// Resource cost of nominal transmission packets, in units
		packetResourceCost = 20.0
		
		// Resource name to be consumed by transmission
		requiredResource = ElectricCharge
		
		// Animation module index, 0-based, of the antenna extend/retract animation
		DeployFxModules = 0
		
		// ### AntennaRange Defintions ###
		// Range, in meters, at which the antenna behaves per the "nominal" characteristics above
		// Used with "additive" ranges.
		nominalRange = 10000000000
		
		// Range, in meters, at which the antenna behaves per the "nominal" characteristics above
		// Used with "simple" ranges.
		simpleRange = 56250000000
		
		// The maxmimum multiplier on packetResourceCost, essentially defining the maximum power output of the
		// transmitter.  Maximum range is defined as: maxTransmitDistance = nominalRange * sqrt(maxPowerFactor)
		maxPowerFactor = 16
		
		// The maximum multiplier on packetSize, essentially defining the maximum data throughput of the
		// transmitter.
		maxDataFactor = 2
	}
	
	// We add this ModuleScienceContainer so that when transmission fails the antennas can try to stash the data instead of dumping it to the void.
	MODULE
	{
		name = ModuleScienceContainer

		dataIsCollectable = true
		dataIsStorable = false

		storageRange = 2
	}
}

This example assumes that the base part definition does not include a ModuleDataTransmitter module, or any RT modules. If the base part definition includes a ModuleDataTransmitter module, a sample AntennaRange patch could look like this:

@PART[modPartName]:FOR[YourModName]:NEEDS[AntennaRange,!RemoteTech]
{
	@MODULE[ModuleDataTransmitter]
	{
		@name = ModuleLimitedDataTransmitter
		nominalRange = 10000000000
		simpleRange = 56250000000
		maxPowerFactor = 16
		maxDataFactor = 2
	}
	
	// We add this ModuleScienceContainer so that when transmission fails the antennas can try to stash the data instead of dumping it to the void.
	MODULE
	{
		name = ModuleScienceContainer

		dataIsCollectable = true
		dataIsStorable = false

		storageRange = 2
	}
}

IIRC, RemoteTech parts should not have ModuleDataTransmitter definitions. In that case, to facilitate RT, AR, and Stock compatibility, a suite of patches like this might be appropriate:

// If we don't have RemoteTech, add a stock ModuleDataTransmitter first.
@PART[modPartName]:NEEDS[!RemoteTech]:BEFORE[YourModName]
{
	MODULE
	{
		// ### Module Definition ###
		name = ModuleDataTransmitter
		
		// ### Squad Definitions ###
		// Delay between transmission packets, in seconds
		packetInterval = 0.10
		
		// Data capacity of nominal transmission packets, in MiT
		packetSize = 2
		
		// Resource cost of nominal transmission packets, in units
		packetResourceCost = 20.0
		
		// Resource name to be consumed by transmission
		requiredResource = ElectricCharge
		
		// Animation module index, 0-based, of the antenna extend/retract animation
		DeployFxModules = 0
	}
}

// If AntennaRange is installed, convert that to a ModuleLimitedDataTransmitter
@PART[modPartName]:NEEDS[AntennaRange,!RemoteTech]:FOR[YourModName]
{
	@MODULE[ModuleDataTransmitter]
	{
		// ### Module Redefinition ###
		@name = ModuleLimitedDataTransmitter
		
		// ### AntennaRange Defintions ###
		// Range, in meters, at which the antenna behaves per the "nominal" characteristics above
		// Used with "additive" ranges.
		nominalRange = 10000000000
		
		// Range, in meters, at which the antenna behaves per the "nominal" characteristics above
		// Used with "simple" ranges.
		simpleRange = 56250000000
		
		// The maxmimum multiplier on packetResourceCost, essentially defining the maximum power output of the
		// transmitter.  Maximum range is defined as: maxTransmitDistance = nominalRange * sqrt(maxPowerFactor)
		maxPowerFactor = 16
		
		// The maximum multiplier on packetSize, essentially defining the maximum data throughput of the
		// transmitter.
		maxDataFactor = 2
	}

	// We add this ModuleScienceContainer so that when transmission fails the antennas can try to stash the data instead of dumping it to the void.
	MODULE
	{
		name = ModuleScienceContainer

		dataIsCollectable = true
		dataIsStorable = false

		storageRange = 2
	}
}

// If RemoteTech is installed, do their module(s) instead
@PART[modPartName]:NEEDS[RemoteTech]:FOR[YourModName]
{
	// RemoteTech module(s) here
}

Useful Formulas

Per Antenna

nominalRange is a given, and is never calculated maxPowerFactor is a given, and is never calculated maxTransmitDistance = nominalRange * sqrt(maxPowerFactor)

Per Link

A "link" is any connected pair of antennas.
NominalLinkDistance = sqrt(nominalRange1 * nominalRange2)
MaxLinkDistance = sqrt(maxTransmitDistance1 * maxTransmitDistance2)

Therefore, to find the MaxLinkDistance from two sets of nominalRange and maxPowerFactor:
MaxLinkDistance = sqrt(nominalRange1 * sqrt(maxPowerFactor1) * nominalRange2 * sqrt(maxPowerFactor2))

To find a single antenna's nominalRange from a desired maxTransmitDistance given its maxPowerFactor:
nominalRange = maxTransmitDistance / sqrt(maxPowerFactor)

To find a single antenna's desired maximum range given the desired maximum link distance and another set maxTransmitDistance:
maxTransmitDistance1 = MaxLinkDistance * MaxLinkDistance / maxTransmitDistance2

Remember that maxPowerFactor may differ between antennas (and does, in my lastest configs: longAntenna is 8, mediumDish is 4, commDish is 16).

Currently Kerbin's maxPowerFactor is hard-coded as 8.

Feel free to use this spreadsheet for balancing antennas if it's useful to you: https://goo.gl/ChsbfL

On Balance

In my configs I've balanced the three stock antennas to cover all of the stock solar system. Since you're introducing five more antennas and working with OPM, you will probably want to change the behavior of the stock parts and diversify the range to gradually cover the whole OPM system. Since you have some parts specifically designed for use in planetary subsystems, their balance when transmitting to other parts is probably more important than their balance when transmitting to Kerbin. For longer range parts designed to make the whole interplanetary leap, the inverse is probably true.

Feel free to ask questions! If anything's unclear or you just want to bounce balance ideas off of me, don't be shy. I'm always happy to help.

antennarange's People

Contributors

linuxgurugamer avatar toadicus avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

antennarange's Issues

AntennaRange causes EVAManager to provide unlimited electricity

See toadicus/EVAManager#2

Potential Fix:

diff --git a/GameData/AntennaRange/AntennaRange.cfg b/GameData/AntennaRange/AntennaRange.cfg
index 8515193..8909f98 100644
--- a/GameData/AntennaRange/AntennaRange.cfg
+++ b/GameData/AntennaRange/AntennaRange.cfg
@@ -130,8 +130,8 @@ EVA_MODULE
 EVA_RESOURCE
 {
        name = ElectricCharge
-       amount = 100
+       amount = 0
        maxAmount = 100
 }

Kerbal EVA Antennas should use much less electricity

The Kerbal EVA Antenna feature relies on EVA Manager, which in turn pulls/returns resources from the pod. Requiring 100 electric charge is prohibitive early in the game (as well as buggy - see bug report in EVA Manager).

Given that the idea is to have a VERY short range antenna, using 10 EC and tweaking the kerbal antenna module suitably makes more sense (IMHO).

Otherwise you end up with an unbalanced situation:

Either Kerbals contribute significantly to the energy budge of a ship if they come with fully-loaded batteries in the early game
or
Kerbals drain their pods of electricity when they go on EVA, leaving the pod unable to act as relay (or for multi-Kerbal pods, out of control)

Transmitting on EVA: ArgumentOutOfRangeException: Argument is out of range

KSP 1.1 w/ AR preview:

[LOG 15:57:38.677] Sending data to vessel comms. 1 devices to choose from. Will try to pick the best one
[EXC 15:57:38.679] ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
    System.Collections.Generic.List`1[IScalarModule].get_Item (Int32 index)
    ModuleDataTransmitter.GetFxModuleScalar (System.Collections.Generic.List`1 modules)
    ModuleDataTransmitter+<transmitQueuedData>c__Iterator68.MoveNext ()
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    ModuleDataTransmitter:TransmitData(List`1)
    AntennaRange.ModuleLimitedDataTransmitter:TransmitData(List`1)
    ModuleScienceExperiment:sendDataToComms(ScienceData)
    KSP.UI.Screens.Flight.Dialogs.ExperimentsResultDialog:onBtnTransmit()
    UnityEngine.EventSystems.EventSystem:Update()

KSP.log.txt

Ship leaving physics range loses connection

Given a ship A carrying a probe B, if you decouple B switch control to it while in physics range (< ~2.2km), then leave physics range, connection is lost and won't be restablished even if within range. You have to switch to A (or some other ship) using the map view and then switch back to B.

Curiously, RemoteTech had the exact same problem in earlier versions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.