Skip to content
Create Custom Status Effects & Chambers authored by Ithirahad Ivrar'kiim's avatar Ithirahad Ivrar'kiim
# Effects
StarMade's modern effect system is based around `ConfigGroup`s containing `EffectConfigElement`s. These config elements in turn contain properties describing what your effect should do.
You can create your own ConfigGroups like so, with a lowercase string tag that will be used to identify them.
```java
ConfigGroup weaponsRangeUpgrade = new ConfigGroup("my_fancy_new_effect");
```
You also have to create and initialize the `EffectConfigElement`s that define what the config group does, and add them to the group.
```java
EffectConfigElement weaponRangeIncElement = new EffectConfigElement();
float rangeBuffAmt = 2.0f; //2x
weaponRangeIncElement.init(WEAPON_RANGE); //determines what the element modifies
weaponRangeIncElement.stackType = ModifierStackType.MULT; //multiplicative modifier (other options are ADD or hard SET)
weaponRangeIncElement.priority = 0; //determines execution order of effect vs. others modifying the same value
StatusEffectFloatValue rangeBuffValue = new StatusEffectFloatValue();
rangeBuffValue.value.set(rangeBuffAmt);
weaponRangeIncElement.value = rangeBuffValue;
weaponRangeUpgrade.elements.add(weaponRangeIncElement); //add the element to the group.
// groups can have multiple elements, e.g. a shield capacity increase ConfigGroup can also include a reciprocal shield upkeep reduction to keep the overall upkeep rate constant.
```
Finally, the `ConfigGroup` has to be enqueued for registration within StarMade itself, within the `RegisterConfigGroupsEvent` that StarLoader provides:
```java
//in main mod
@Override
public void onEnable() {
registerListener(RegisterConfigGroupsEvent.class, new Listener<RegisterConfigGroupsEvent>() {
@Override
public void onEvent(RegisterConfigGroupsEvent event) {
event.getModConfigGroups().enqueue(weaponsRangeUpgrade);
}
}, modInstance);
}
```
Once you have your `ConfigGroup` set up and registered in the queue, you can simply add its name to the `chamberConfigGroupsLowerCase` list in your chamber block's `ElementInformation`:
```java
myChamberBlockInfo.chamberConfigGroupsLowerCase.add("my_fancy_new_effect");
```
...and its effect(s) will be applied to a ship or station whenever the chamber is added.
\-
**NOTE:** Unfortunately, due to their enum nature, it appears that you cannot create custom `StatusEffectType`s. Instead, you can have your custom functionality poll the chamber tree directly to enable or disable itself based on whether or not the relevant chamber is present:
```java
ReactorElement someChamberEle = SegmentControllerUtils.getChamberFromElement(theEntitysManagerUsableSegmentController, chamberBlocksElementInformation);
boolean myChamberIsPresentAndActive = (someChamberEle != null && someChamberEle.isAllValid());
```
\ No newline at end of file