- Edited
Buff Modding
So you consider yourself an advanced modder and think you are ready to do fancy or magic things? Then you are at the right place.
At this point you are expected to have a solid knowledge about modding, mod.txt and most game mechanics. It is recommended you also have a good understanding of math preferable on the higher level side.
As of Cosmoteer 0.14.7 consider the requirements to be closer to master level due to the difficulty increase especially in connection with vanilla parts. If you are not a high level modder do not venture beyond your own mod.
What is a buff?
A buff is a means to manipulate a given statistic (stat) of a part during game play. A part's stats are considered fixed and cannot be changed after setup. Therefore, buffs are the only means to do this.
Starting Out
At this point you have to have an idea how the buff is to be used. And how it's being calculated. See Setup section below for the possible math involved.
Aside from using a buff as just a buff it can also be used as a command signal or as a controlling switch. For example as control mechanism to connect the railgun accelerators or a remote control to detonate explosive charges or as a roof turret spamming restriction.
It can also be used as a counter for determining the loadout under the wings of a fighter in the VariTech transformation mod. (Cosmoteer 0.14.4+, currently isn't counting it right.)
Setup
A buff has to be setup in buff.txt
and applied to vanilla in mod.txt
. As of Cosmoteer 0.14.4 the important parameters of a buff are:
CombineMode
, which determines how the buff is calculated among itself when being received; modes are : Min, Max, Add, MultiplyExponent
, which sets its exponentMultiplier
, which sets the multiplier for it // 0.14.4BaseValue
, in percent which sets a base value to be addedMinValue
, sets the minimum value it can haveMaxvalue
, sets the maximum value it can have
As of Cosmoteer 0.14.4 the buff is a math block which is as follows:
((Buff^Exponent) * Multiplier) + BaseValue
MinValue
and MaxValue
are evaluated or applied after the calulations.
Applying a buff to a part
The buff can be used in a part or a shot or beam. To do this a ReceivableBuffs
list has to be declared which lists all buffs which are to be applied.
Now the part can either be providing the buff or be receiving the buff. A shot or beam that is to receive a buff must be "inheriting" the buff from the part.
To provide a buff a Type = GridBuffProvider
or Type = AreaBuffProvider
or Type = SelfBuffProvider
or Type = CommandProvider
can be used each with their specific abilities.
The GridBuffProvider is meant for adjacent or surrounding parts while the AreaBuffProvider is for a rectangle area, the difference is in the computational cost and placement. AllowDiagonals
can be used to allow diagonally placed parts to be affected.
The SelfBuffProvider is for the part itself. The CommandProvider is only for control room parts.
Providers can have a Criteria
subcomponent which is an enabler based on the placement and orientation of the "connected" part.
Buffs applied to a component parameter are setup as follows:
{ BaseValue=500; BuffType=MyBuff1,MyBuff2; BuffMode=Multiply; }
The BaseValue
is the starting value. BuffType
lists all the buffs that go into the calculation.
BuffMode
sets the type of calculation modes for the buffs and has these options:
- Replace
, the base value will simply be replaced with the buff value.
- Add
, the buff value will be added to the base value.
- Subtract
, the buff value will be subtracted from the base value.
- Multiply
, the base value will be multiplied with the buff value.
- Divide
, the base value will be divided by the buff value.
- Lerp
, the buff value will be used to linearly interpolate between MinValue and MaxValue such that if the
As of Cosmoteer 0.14.7 additional calculations can be applied to a buff for example to change the sensing range for a sensor to send out an alarm (as in Abh 0.6.3).
Applying a buff to vanilla
As of Comsoteer 0.14.7 this is a critical point recommended for really advanced modders. Previous application of add action modifications may no longer apply in mod.txt.
The following are required steps! Missing, cheating or dropping a step can lead to crashes or worse incompatibility and conflict with other mods!
In order to add a buff the first step is to check whether a part already has ReceivableBuffs
list or not. If not we create an empty list.
{
Action = Add
OnlyIfNotExisting = true
AddTo = "<./Data/ships/terran/sensor_array/sensor_array.txt>/Part"
Name = ReceivableBuffs
ToAdd = []
}
Next the buff gets actually added to the ReceivableBuffs
list.
{
Action = AddMany
AddTo = "<./Data/ships/terran/sensor_array/sensor_array.txt>/Part/ReceivableBuffs"
ManyToAdd = [BuffSignal]
}
Special case see Applying a buff to base_part
section.
Now the buff has to be applied and used in the part.
{
Action = Replace
Replace = "<./Data/ships/terran/sensor_array/sensor_array.txt>/Part/Components/Sensor/SightRadius"
With = { BaseValue=800; BuffType=BuffSignal; BuffMode=Multiply; }
}
As of Cosmoteer 0.14.7 changes to a part's stats also requires changes to the Stats
component. References cannot be used or turned over as is and must use ()
.
{
Action = Replace
Replace = "<./Data/ships/terran/sensor_array/sensor_array.txt>/Part/Stats/SensorRange"
With = (&<./Data/ships/terran/sensor_array/sensor_array.txt>/Part/Components/Sensor/SightRadius/BaseValue)
}
Applying a buff to base_part
Currently, (Cosmoteer 0.14.7), this is a potentially, extremely hazardous area in modding! This should only be used by really advanced modders. Currently, there is no means to avoid possible conflicts between mods.
It's not possible to check for categories, buffs, prevent overwriting, adding multiple modes or values. Anything added at this stage should be done with caution and with pre-planning to avoid possible conflict or ID or Keyname collisions.
Like before the firststep is to check whether ReceivableBuffs
list exists or not. If not we create an empty list.
{
Action = Add
OnlyIfNotExisting = true
AddTo = "<./Data/ships/base_part.txt>"
Name = ReceivableBuffs
ToAdd = []
}
Now a buff can be added to the list. Note: AddMany must be used to avoid overwriting an existing list and its contents!
{
Action = AddMany
OnlyIfNotExisting = true
AddTo = "<./Data/ships/base_part.txt>/ReceivableBuffs"
ManyToAdd = [BuffIntegrity]
}
You can add a bunch of buffs at once or individually. Individually would allow you to simply remove or add one.
Special case: As of Cosmoteer 0.14.7 when adding a buff to a part the buffs added to base_part will be overwritten! You will have to re-list them all in the part if you don't want any to be missed.
This will be fixed in future Cosmoteer versions by having ReceivableBuffs
inherit from base_part.
Further leading guides
Master Modding
Appendix
Modding Guideline for Quality Control, "Do's and don'ts for modding"
Extreme Modding only for those perfectionists