Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.98a is out! (03/27/25)

Pages: 1 ... 699 700 [701] 702 703 ... 778

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 2303716 times)

minno

  • Ensign
  • *
  • Posts: 32
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10500 on: February 23, 2024, 01:10:57 PM »

Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 26038
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10501 on: February 23, 2024, 07:44:35 PM »

The first is, I need to make a global boolean value to record whether this person is met or not. Like player.metSiyavong in the vanilla game. Do I need to create a new boolean method under the class of the object player? I don't think this idea is practible.

Take a look at MemoryAPI in the javadoc.
https://fractalsoftworks.com/forum/index.php?topic=7164.0

You can access the $global memory using Global.getSector().getMemoryWithoutUpdate().

The second is, for some reason, after I add the person to Global.getSector().getImportantPeople(), everything works well, and the person has his sprite and visual as expected when I see him on the stations. But when I tried to call ShowPersonVisual after calling ShowImageVisual tomas_kol, nothing happens. Do I need to undo the ShowImageVisual first, or is it just there is something wrong with the ShowImageVisual? I didn't find any example about doing this.

Ah - you want to use ShowPersonVisual instead.

ShowPersonVisual <true or false> <person id>

The second parameter is whether it'll also show the faction flag/relationship bar, iirc.


Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

I'm not actually sure which sound you mean. IIRC missile engines don't play a sound when they flame out? And they also don't play a sound when they fade out.


Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().
Logged

Tranquility

  • Captain
  • ****
  • Posts: 291
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10502 on: February 23, 2024, 09:11:15 PM »

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)
« Last Edit: February 23, 2024, 09:20:09 PM by Tranquility »
Logged

VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10503 on: February 24, 2024, 09:18:25 AM »

The first is, I need to make a global boolean value to record whether this person is met or not. Like player.metSiyavong in the vanilla game. Do I need to create a new boolean method under the class of the object player? I don't think this idea is practible.

Take a look at MemoryAPI in the javadoc.
https://fractalsoftworks.com/forum/index.php?topic=7164.0

You can access the $global memory using Global.getSector().getMemoryWithoutUpdate().

The second is, for some reason, after I add the person to Global.getSector().getImportantPeople(), everything works well, and the person has his sprite and visual as expected when I see him on the stations. But when I tried to call ShowPersonVisual after calling ShowImageVisual tomas_kol, nothing happens. Do I need to undo the ShowImageVisual first, or is it just there is something wrong with the ShowImageVisual? I didn't find any example about doing this.

Ah - you want to use ShowPersonVisual instead.

ShowPersonVisual <true or false> <person id>

The second parameter is whether it'll also show the faction flag/relationship bar, iirc.


Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

I'm not actually sure which sound you mean. IIRC missile engines don't play a sound when they flame out? And they also don't play a sound when they fade out.


Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().

Thank you! Alex, your suggestions worked!

By the way, I think Originem was talking about the situation when the missiles travel longer than their projectile life time, and blow themselves into dusts. It'll make a sound that sounds like a low blow sound of "pang". I guess it's the sound when the projectile getting destroyed.
« Last Edit: February 24, 2024, 09:20:27 AM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:

Ruddygreat

  • Admiral
  • *****
  • Posts: 585
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10504 on: February 24, 2024, 09:23:09 AM »

Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv

minno

  • Ensign
  • *
  • Posts: 32
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10505 on: February 24, 2024, 12:31:37 PM »

Is there an API for getting the current "proximity to other colonies" accessibility bonus/penalty on a planet that hasn't been colonized yet? All I've found is PlanetAPI -> SectorEntityToken.getMarket -> MarketAPI.getAccessibilityMod, but that only seems to show the permanent effects of the low/high gravity planet conditions. Nothing apparent in StarSystemAPI or util.Misc either.

Ah, sorry, this calcualtion is done in core code somewhere. If you look for a flat modifier with id "core_base" you could probably get its value from MarketAPI.getAccessibilityMod().

That doesn't seem to work. planet.getMarket().getAccessibilityMod().getFlatBonus("core_base") gives me null. planet.getMarket().getAccessibilityMod().computeEffective(0f) gives me just 0, 0.1, or -0.1 depending on if it has high/low gravity, so it doesn't look like that modifier is in there.

I found a workaround, though. The accessibility bonus when only the vanilla core worlds are populated is pretty much determined by distance from Askonia, which is easy enough to look up.
Logged

VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10506 on: February 24, 2024, 02:03:57 PM »

Is there anyway to remove the missile destoryed sound (after reaching its lifetime)?

(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv

Thank you!
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:

VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10507 on: February 24, 2024, 02:10:22 PM »

Hi everyone, I'm back with some silly questions,

After succesfully creating my character, and adding all the dialogues, I want to make him a contact to offer some missions.

Everything worked fine as I mimick the vanilla game. But when I was trying to let him offer military bounties, something weird happens and I don't know how to solve.

So I copied the MilitaryCustomBounty file, coded it properly so that things worked out. The person offers military bounties and I can take the mission, the bounties worked jut fine.

But I can't see anything regarding the bounty information in the dialogue. I believe I'm missing some files corresponding to $mcb_ref showBountyDetail and $mcb_ref showBountyAssessment in the rules.csv. But I can't find any class called mcb_ref or any methods in the starfarer.api so far. I may also be missing the triggers. Currently I'm using my own bounty creater names as triggers, but I don't know how to define new triggers, is there any examples about doing that? And in general, my guesses could all be wrong, please let me know what am I missing if that does happen.

I also met another problem I can't solve.

Question 2: I defined a custom bounty following the vanilla CBRemnantPlus.java file, and the starsector.log tells me that the following code is problematic:      

      picker.add("tesseract_Attack");
      picker.add("tesseract_Attack2");
      picker.add("tesseract_Strike");
      picker.add("tesseract_Disruptor");
      fleet.getFleetData().addFleetMember(picker.pick());

It says: No applicable constructor/method found for actual parameters "java.lang.Object"; candidates are: "public abstract void com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(com.fs.starfarer.api.fleet.FleetMemberAPI)", "public abstract com.fs.starfarer.api.fleet.FleetMemberAPI com.fs.starfarer.api.campaign.FleetDataAPI.addFleetMember(java.lang.String)"

Similar reports to the code:

      int i = data.fleet.getFleetData().getMembersListCopy().size() - 1;
      FleetMemberAPI last = data.fleet.getFleetData().getMembersListCopy().get(i);
      data.fleet.getFleetData().removeFleetMember(last);

It seems that somehow the picker.pick() does something wrong, the object class for its return gets lost. And the data.fleet goes wrong. If I avoid using the picker.pick() method at all, and I don't use data.fleet.getFleetData().getMembersListCopy().get() method at all, then the code runs fine. Now I'm even more confused. The following are all my imports:

package data.scripts.campaign.intel.missions;

import java.util.List;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.AICoreOfficerPlugin;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.campaign.econ.MarketAPI;
import com.fs.starfarer.api.characters.PersonAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.campaign.FleetDataAPI;
import com.fs.starfarer.api.impl.campaign.missions.cb.BaseCustomBountyCreator;
import com.fs.starfarer.api.impl.campaign.missions.cb.CBStats;
import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.FleetTypes;
import com.fs.starfarer.api.impl.campaign.ids.Skills;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithBarEvent;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetQua lity;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.FleetSiz e;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerN um;
import com.fs.starfarer.api.impl.campaign.missions.hub.HubMissionWithTriggers.OfficerQ uality;
import com.fs.starfarer.api.impl.campaign.missions.hub.ReqMode;
import com.fs.starfarer.api.loading.VariantSource;
import com.fs.starfarer.api.util.Misc;
import com.fs.starfarer.api.util.WeightedRandomPicker;

This is strange, is it because I forgot some imports? I didn't use a compiler and I don't have any .jar files, because I want to get more familiar with how the vanilla game works.

Please let me know, any help will be greatly appreciated!
« Last Edit: February 24, 2024, 09:43:06 PM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:

Tranquility

  • Captain
  • ****
  • Posts: 291
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10508 on: February 24, 2024, 07:45:05 PM »

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

...

While I'm still waiting for a response to this, I actually do have another, more general question to ask. What's the recommended way to seamlessly add a modded Colony Crisis into the game. So far, I just have this to spawn in the crisis for my faction during a game load:

Code: java
    @Override
    public void onGameLoad(boolean newGame) {
        # stuff
        addAdversaryColonyCrisis();
        # stuff
    }

    private void addAdversaryColonyCrisis() {
        HostileActivityEventIntel intel = HostileActivityEventIntel.get();
        if (intel != null && intel.getActivityOfClass(AdversaryHostileActivityFactor.class) == null) {
            AdversaryHostileActivityFactor adversaryFactor = new AdversaryHostileActivityFactor(intel);
            intel.addActivity(adversaryFactor, new AdversaryActivityCause(intel));
            intel.addActivity(adversaryFactor, new AdversaryActivityCause2(intel));
        }
    }
But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.

VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10509 on: February 25, 2024, 01:59:25 PM »

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

rules.csv Condition for a PopulateOptions trigger (Highlighted is the problem condition)
$isPerson
$personFaction.id == adversary
$player.fcm_faction == adversary
Commission personCanGiveCommission
!$player.defeatedAdversaryAttack
!$global.adversary_mt_ref
[close]
In Devmode, after going through my dialogue, triggering the script, and then dumping the memory, I can see it clearly as $global.adversary_mt_ref = MutualTenacityScript@[object #], but, for whatever reason (and this is my guess), the !$global.adversary_mt_ref condition still thinks that that memory key doesn't exist, making the condition always true when I expect it to be false at that point. All other conditions seem to work fine, and, from what I can find, the other times I used !$global.[memKey] to check for global memory keys had worked as intended. It's only that !$global.adversary_mt_ref condition check that isn't working as I thought it would.

If this is an unsupported feature (or just user error), what would be the intended solution for checking memory keys containing a non-boolean object in rules.csv?

(Oh, and I used the PiracyRespiteScript.java, which contains "$prf_ref" as its key, as a reference for my own script. I didn't see its memory key get used anywhere in the vanilla rules.csv, though, so there wasn't anything else I could fall back on for help with this problem.)

Hi Tranquility, I think I can solve this. It seems to me that you are not using the right codes. For a variable, say $x (for simplicity), the condition !$x written in the rules means "Assuming that $x is a boolean variable, and if its value is false, then this condition is true". I would not suggest using the method !$x in rules.csv if $x is not boolean, because according to my experiences, it seems that the !$x treats non-boolean variables $x or null variables $x as if they were false boolean values by default. I would suggest defining a function that takes value of $global.adversary_mt_ref, examines whether it's null, and returns another global boolean value $result. Then you may use !$result in rules.csv.
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:

VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10510 on: February 25, 2024, 02:16:44 PM »

I've been trying to make a dialogue option only appear if a memory key containing my script does not exist (i.e. is null). However, if I use the !$[memKey] condition in rules.csv to check for that, it doesn't appear to work correctly, so the dialogue still appears even when that script exists and is stored in the specified memory key.

...

While I'm still waiting for a response to this, I actually do have another, more general question to ask. What's the recommended way to seamlessly add a modded Colony Crisis into the game. So far, I just have this to spawn in the crisis for my faction during a game load:

Code: java
    @Override
    public void onGameLoad(boolean newGame) {
        # stuff
        addAdversaryColonyCrisis();
        # stuff
    }

    private void addAdversaryColonyCrisis() {
        HostileActivityEventIntel intel = HostileActivityEventIntel.get();
        if (intel != null && intel.getActivityOfClass(AdversaryHostileActivityFactor.class) == null) {
            AdversaryHostileActivityFactor adversaryFactor = new AdversaryHostileActivityFactor(intel);
            intel.addActivity(adversaryFactor, new AdversaryActivityCause(intel));
            intel.addActivity(adversaryFactor, new AdversaryActivityCause2(intel));
        }
    }
But that means if the Colony Crisis intel gets added mid-game, the custom Crisis will not get put in too (and, thus, not contribute towards the event) unless the game was saved and then reloaded. Also, if the CC intel gets removed (due to losing all colonies at once) and then gets added back in, the custom Crisis will temporarily disappear until yet another save reload. Not exactly the biggest deal for what I've planned with my faction, but, if possible, I'd appreciate a way to avoid those edge cases and cleanly implement a custom Colony Crisis.

Hi Tranquility,I believe you may add the custom colony crisis in new game, or together with sector creation, make it sleep. Then create a global boolean variable (or maybe a set of global boolean values) to keep track of the hostility intel, set it to false in the beginning, and use this global boolean value to determine whether your colony crisis should sleep or not. I think it's just easier to split this task of adding a colony crisis in two parts, instead of trying to do everything at once.
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:

Tranquility

  • Captain
  • ****
  • Posts: 291
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10511 on: February 25, 2024, 03:46:50 PM »

...

Hi Tranquility, I think I can solve this. It seems to me that you are not using the right codes. For a variable, say $x (for simplicity), the condition !$x written in the rules means "Assuming that $x is a boolean variable, and if its value is false, then this condition is true". I would not suggest using the method !$x in rules.csv if $x is not boolean, because according to my experiences, it seems that the !$x treats non-boolean variables $x or null variables $x as if they were false boolean values by default. I would suggest defining a function that takes value of $global.adversary_mt_ref, examines whether it's null, and returns another global boolean value $result. Then you may use !$result in rules.csv.

Hi, I ended up just making a custom BaseCommandPlugin class - that I can call in rules.csv - to address both my original issue and other issues that I came about since then. Kinda unfortunate that, as you said, !$x still treats non-boolean variables as false, but I did manage to work around that limitation anyways. Appreciate the help, though!

...

Hi Tranquility,I believe you may add the custom colony crisis in new game, or together with sector creation, make it sleep. Then create a global boolean variable (or maybe a set of global boolean values) to keep track of the hostility intel, set it to false in the beginning, and use this global boolean value to determine whether your colony crisis should sleep or not. I think it's just easier to split this task of adding a colony crisis in two parts, instead of trying to do everything at once.

I'm not too sure on what you meant here, but, to clarify further, I basically wanted a way to effectively "attach" the custom Colony Crisis script to the main Colony Crisis intel object whenever the main CC intel gets created, as to avoid needing to do continuous and/or redundant checks (like making a custom EveryFrameScript, using the ModPlugin load() methods, having an unrelated listener run the script occasionally, etc.) if said CC intel doesn't exist or gets removed mid-game. If there isn't an "official" way to do this (i.e. nothing in the API that would allow for running scripts when the CC intel starts existing), I would either have to make a custom listener that runs whenever the CC intel gets created, or just have the custom script also run continuously on one of my existing listeners and call it a day - which, ok, not perfect, but an improvement over running it only a single time with onGameLoad().

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10512 on: February 25, 2024, 05:23:05 PM »

(and vladimirvv and alex)

that's added by graphicslib, you'll need to add the missile to it's no debris whitelist csv
Oh thanks! I even didn't notice that!
Logged
My mods


Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 432
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10513 on: February 26, 2024, 03:33:14 AM »

Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....
Logged
My mods


VladimirVV

  • Commander
  • ***
  • Posts: 249
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10514 on: February 26, 2024, 08:01:36 AM »

Is there any way to get missile's id from WeaponAPI?
There is no getId in MissileSpecAPI....

If you want to get the Id of the weapon that launches your missile, maybe you want to try method getProjectileSpecId() from DamagingProjectileAPI.
Logged
Greetings from the P-Space! --Captain Vladimir
My Mods:
Pages: 1 ... 699 700 [701] 702 703 ... 778