Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 700 701 [702] 703 704 ... 710

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

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10515 on: February 26, 2024, 06:37:29 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!

I'm still stuck at these problems, and mean while i did some experiments to find some clues. After I see the results, I'm even more confused than I was. So the following are what I did:

1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.
Logged
Greetings from the P-Space! --Captain Vladimir

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10516 on: February 27, 2024, 11:58:22 AM »

(Augh, sorry for not responding for a while here! Got sidetracked, and also, after the thread has been stickied, I keep not seeing it - just not used to where to look, still.)

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.)

Yeah, the ! (not) operator is not going to work to check for the existence of a key like this. Generally when vanilla goes this sort of thing, the reference is a mission or some other type of CallableEvent, so using Call $<ref> <action id> would return false if the reference is not set.

You could also create your own custom rule command - ah, I see you already did that. Nice!

For the next release, I've made it so that the == null check works. != null already works, by the way.



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.

$mcb_ref is a reference to the MilitaryCustomBounty mission. That class extends BaseCustomBounty, and that has a callAction() method that handles these calls.



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)"

Have you set up an IDE? There are some instructions for how to do this floating around on the forum and on the wiki. At this point, it sounds like you would save some time by doing this, as - when set up properly - a dev environment would catch these sorts of things for you immediately, and point you to what you need to do.


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.

Hmm, you're right, actually. For the moment you'd probably want to set up a script that uses an IntervalUtil to run these checks every few seconds.

Made a note to add a completely clean way of doing this.

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

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:


1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.

This sounds like changing the mission id to "mcb" is making use of some vanilla rules that you maybe didn't have duplicated for your specific mission? I'd be concerned that this may only seem to be working and something else might've broken. For example, if the mission id is mcb now, you've *replaced* the vanilla mcb mission with yours!

In particular also if variables were missing make sure about calling Call $mcb_ref updateData in your "conditions" column.

But, honestly, it's hard to say exactly what's going on here; I don't really have a full overview and it's hard to take in that much info at a glance. If I might suggest more bite-size increments, making things work one step at a time?
Logged

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10517 on: February 27, 2024, 01:55:53 PM »

(Augh, sorry for not responding for a while here! Got sidetracked, and also, after the thread has been stickied, I keep not seeing it - just not used to where to look, still.)

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.)

Yeah, the ! (not) operator is not going to work to check for the existence of a key like this. Generally when vanilla goes this sort of thing, the reference is a mission or some other type of CallableEvent, so using Call $<ref> <action id> would return false if the reference is not set.

You could also create your own custom rule command - ah, I see you already did that. Nice!

For the next release, I've made it so that the == null check works. != null already works, by the way.



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.

$mcb_ref is a reference to the MilitaryCustomBounty mission. That class extends BaseCustomBounty, and that has a callAction() method that handles these calls.



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)"

Have you set up an IDE? There are some instructions for how to do this floating around on the forum and on the wiki. At this point, it sounds like you would save some time by doing this, as - when set up properly - a dev environment would catch these sorts of things for you immediately, and point you to what you need to do.


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.

Hmm, you're right, actually. For the moment you'd probably want to set up a script that uses an IntervalUtil to run these checks every few seconds.

Made a note to add a completely clean way of doing this.

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

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:


1-I changed the mission name to mcb in the person_mission csv file instead of my faction's special mcb name, call it tomas_mcb
2-I changes everything in my rules csv accordingly, directly copying from vanilla rules.csv for the mcb rule lines, and added some conditions, changed the rules id, as if I have made a new voice for the vanilla mcb mission.

Then it magically worked, a lot of mcb variables that were not there when I was using my alternative version of the custom bounty file were created. And I don't know why by adding a condition to the person_mission csv file in my mod that says id: mcb, conditions: id == tomas_kol would not block other npc's from offering mcb bounties. I thought it would. I don't know why this would work, I don't know why my version didn't work, and I'm just more confused.

This sounds like changing the mission id to "mcb" is making use of some vanilla rules that you maybe didn't have duplicated for your specific mission? I'd be concerned that this may only seem to be working and something else might've broken. For example, if the mission id is mcb now, you've *replaced* the vanilla mcb mission with yours!

In particular also if variables were missing make sure about calling Call $mcb_ref updateData in your "conditions" column.

But, honestly, it's hard to say exactly what's going on here; I don't really have a full overview and it's hard to take in that much info at a glance. If I might suggest more bite-size increments, making things work one step at a time?

Thank you Alex. I was just trying to see how far can I go without making a jar. It seems that I get stuck at making quests. Then I will install and configure an IDE. And it seems that we do need jar files to create new quests. I tried to simply pull some java files of vanilla quests out of the jar, and immediately I got an error saying that the game doesn't understand the enum Stage definition and expects a ";" instead of "{". Too bad, I thought I could make a mod without using jar at all :(

By the way, for the mcb mission, strange, right? I thought it would replace the vanilla mcb as well, but it didn't. I was able to get vanilla mcb missions as usual, and I used devmode to verify, they were actually military bounty instead of underworld bounties. These military bounties does not follow my mcb rules (I removed several mcb bounties from generating, but these vanilla military bounties ignore those restrictions). And the even more strange thing is, I set $missionId to be my version of mcb (tomas_mcb), and I set mission Id in the person_mission file to be mcb. So there is actually no mission called tomas_mcb at all, I thought this would break the game, but it just magically worked. I hope someone could give an explanation to why this would happen. I'm happy to share more details.
« Last Edit: February 27, 2024, 08:26:04 PM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10518 on: February 27, 2024, 08:25:07 PM »

Hello, everyone, I'm back with some more silly questions.

So I tried to set up an IDE, and started building .jar files. I used eclipse (for some reason that's the only IDE working for me.), and the building was successful.

I configured the JRE's and compiler settings to JRE 7, and the attached are my setting pics.

But then I still encounter a major.minor version 52 error when trying to launch my mission file in my jar.

I believe I'm missing something as I tried to set the compile target to JRE 7. I thought it would be OK if I configure the compiler version and jre preference, but I don't know exactly how to do that with eclipse.

« Last Edit: February 28, 2024, 11:06:54 AM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10519 on: February 28, 2024, 04:26:16 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!

OK, though I'm still stuck on the java version, I found a solution to my old silly questions, and I'll post them here just in case it could help someone.

To my first silly question, my answer is: I was actually not missing anything. The onlything wrong was that I should've changed all the variable names, i.e. $mcb_ref to $tomas_mcb_ref. Because after examining the BaseCustomBounty file, I found that these variables are actually generated using the mission Id, which is tomas_mcb, plus _ref. So by doing mcb_ref, both showBountyDetail method and showBountyAssessment method would not work. After making these small changes and using my version of mcb quest java file, everything works out, the tomas_mcb mission is now functional.

To my second silly question, my answer is: Well, after examining it using the eclipse IDE, unfortunately this is an issue caused by compilation. The result returned by the picker.pick method would not be recognized properly if it were not compiled into a .jar file. Similar behavior is observed in enum objects, they just can't live in the game if they exist in a java file that's not compiled into a jar.

And, I discovered that all the vanilla contact missions can be implemented without a .jar file. Then I continue my experiments to see can I somehow generalize this idea to a way of creating bounties with any fleet without using a .jar. I did it, it worked. The only thing I need to do is copy a vanilla CBCreater file (let's say CBRemnantPlus), modify it and rename it properly (let's say tomas_CBRemnantPlus), add this to the CREATOR List in tomas_MilitaryCustomBounty.java file, and we are done with the codes. Then to the rules.csv, add corresponding rules for tomas to say proper words describing the bounty. And change the trigger from MCBShowBounty to tomasMCBShowBounty. Everything worked fine.

It turns out what caused the strange problem was that I didn't change the trigger in the rules.csv file, I used the trigger MCBShowBounty, but the Military Custom Bounty file contains a bounty creater NOT in the CREATOR List of the vanilla MCBShowBounty file, and things get broken. Everything worked properly after I changed the trigger. I also want to make a remark (to whoever that may read my silly questions) that, you do NOT need to define the trigger using separate scripts, you can let your custom trigger be an arbitrary string and call it after FireBest or FireAll. I thought all triggers should be defined using some codes, and that's why I didn't change the trigger name.
« Last Edit: March 01, 2024, 01:02:25 AM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10520 on: February 28, 2024, 06:09:16 PM »

API request: RemoveOption rulecmd currently causes all remaining options to forget whether they were disabled. It should not do this.

e.g. this modded bug involves a mod dialog option being disabled but then having that setting removed by a separate vanilla dialog option, so I have to catch the invalid state after the mod option is selected as well as before
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10521 on: February 28, 2024, 09:10:08 PM »

Ah, that's... unfortunate. The implementation of RemoveOption has some limitations, it definitely does not handle everything. I'll make a note of this specific thing, but improving the implementation to handle these kinds of cases is fairly complicated.
Logged

Originem

  • Purple Principle
  • Captain
  • ****
  • Posts: 430
  • Dancing like a boss.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10522 on: February 29, 2024, 01:56:32 AM »

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:
Wait what? hull spec  hull id??
And is there something missing?
Logged
My mods


VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10523 on: February 29, 2024, 09:01:29 PM »

Hello, everyone, I'm back with some more silly questions.

So I tried to set up an IDE, and started building .jar files. I used eclipse (for some reason that's the only IDE working for me.), and the building was successful.

I configured the JRE's and compiler settings to JRE 7, and the attached are my setting pics.

But then I still encounter a major.minor version 52 error when trying to launch my mission file in my jar.

I believe I'm missing something as I tried to set the compile target to JRE 7. I thought it would be OK if I configure the compiler version and jre preference, but I don't know exactly how to do that with eclipse.

OK, I'm back with an answer to my silly question. It seems that I need to check a box in the export options. As shown in the attached. After checking that box saying JRE 7, the version issue was solved.
Logged
Greetings from the P-Space! --Captain Vladimir

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10524 on: March 01, 2024, 09:27:47 AM »

MissileSpecAPI.getHullSpec().getHullId() *may* work.

But yeah, this sounds like the right way to go:
Wait what? hull spec  hull id??
And is there something missing?

Missiles are have a fake hull spec to hold their engine data; I don't remember off the top of my head what fields are set for it and the id *might* be set to the missile projectile ID. But it might also not be. That's all I meant.


@VladimirVV: glad you got it figured out!
Logged

Dagg_r

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10525 on: March 02, 2024, 10:22:06 AM »

Hello, I'm new on this forum but a long time player.

I'm trying to keep destroyed ship hulks from disappearing, I'm almost sure it's impossible but still asking here to be certain.

Hulk pieces disappear after 90 seconds, while whole ship hulks don't disappear until there are too many hulks on the map. I looked in the json configurations but didn't find anything relevant, then I dug through the API to see if there is something that controls this, specifically in CombatEngineAPI, but didn't find anything.

Then what I did is hijack a mod that had a plugin that extends BaseEveryFrameCombatPlugin which iterates over hulks, and then I tried various things in the advance method :
  • ship.setHitpoints(10000) : I thought maybe hulks have decaying hull ? But no, this doesn't work.
  • ship.setHulk(false) : Immediately makes the hulk disappear.
  • ship.setTimeDeployed(0) : Doesn't work.

Am I missing anything ?
Logged

VladimirVV

  • Lieutenant
  • **
  • Posts: 81
  • Captain Vladimir Reporting In!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10526 on: March 03, 2024, 08:33:32 AM »

Hello, everyone, I'm back with some more silly questions.

So now I'm adding some story missions to my mod. Let's say I have tomas_kol, and I have macario. Now I finish the usurpers, and I want to get Macario a dialogue option I can choose to ask about tomas. According to the vanilla rules.csv, there is already a default macario greeting after finishing the usurpers, and it does not fire any PopulateOptions.

So far what I did was that I added a macario greeting rule, saying that if the player is on the tomas mission, then when the trigger PickGreeting happens, under condition !$global.PlayerAskedMacarioAboutTomas && $global.TomasMissionStarted, it will do the script FireBest Populate Options, and it seems to work just fine.

I have two concerns, my first concern is, if I use FireBest, then what if the player is concurrently on another mission that also involves macario, and macario will only offer one option from both options as he should offer.

And my second concern is, if I change FireBest to FireAll, then Macario will Not offer any options when he picks greetings, I believe this is due to the vanilla rule, and I need to cut commlink and greet him again to let him offer options.

I think FireAll PopulateOptions should be the proper way to do this, I might be wrong. But what is the proper way for me to let macario fire all PopulateOptions without needing to cut comm link first?

Update: I have solved my silly question. After some tests, I found that if I add another condition to the tomas mission macario greeting that !$global.TomasMissionCompleted, the FireAll actually worked. And so FireAll PopulateOptions should be the proper way to do this, it's just I need to set up the greeting conditions correctly so that it would not get overrided by the vanilla macario greeting rule.
« Last Edit: March 03, 2024, 09:17:24 AM by VladimirVV »
Logged
Greetings from the P-Space! --Captain Vladimir

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10527 on: March 03, 2024, 08:34:09 AM »

how does PlanetAPI.setSecondLight() work?
I'm setting it in an EveryFrameScript with runWhilePaused returning true but it only ever actually works while the game is paused, if I unpause the planet goes back to being unlit.

later edit : I've also checked with a debugger, the planet's secondLightColor & secondLightLocation fields do get properly filled out wether the game is paused or not

I've also tried setting it once when the planet is generated, but that didn't seem to work either

the script that gets added to the system the planet is in
(I also use this to block transverse jumping out of the system)
Code
public class SSCHomeSystemTJBlocker implements EveryFrameScript {

    public final StarSystemAPI system;

    public SSCHomeSystemTJBlocker(StarSystemAPI system) {
        this.system = system;
    }

    @Override
    public boolean isDone() {
        return false;
    }

    @Override
    public boolean runWhilePaused() {
        return true;
    }

    @Override
    public void advance(float amount) {

        CampaignFleetAPI playerFleet = Global.getSector().getPlayerFleet();

        if (playerFleet.getContainingLocation() != system) return;

        PlanetAPI planet = (PlanetAPI) Global.getSector().getEntityById(IDs.gardenPlanetID);
        SectorEntityToken SSCStation = Global.getSector().getEntityById(IDs.cronusStationID);
        planet.setSecondLight(
                new Vector3f(SSCStation.getLocation().x, SSCStation.getLocation().y, SSCStation.getCircularOrbitRadius() * 0.75f),
                new Color(255, 225, 125, 255)
        );

        if (!playerFleet.hasAbility(Abilities.TRANSVERSE_JUMP)) return;
        if (playerFleet.getAbility(Abilities.TRANSVERSE_JUMP) == null) return;

        playerFleet.getAbility(Abilities.TRANSVERSE_JUMP).setCooldownLeft(Global.getSettings().getAbilitySpec(Abilities.TRANSVERSE_JUMP).getDeactivationDays());

    }
}
[close]
« Last Edit: March 03, 2024, 01:23:58 PM by Ruddygreat »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10528 on: March 04, 2024, 09:34:19 AM »

Hello, I'm new on this forum but a long time player.

I'm trying to keep destroyed ship hulks from disappearing, I'm almost sure it's impossible but still asking here to be certain.

Hulk pieces disappear after 90 seconds, while whole ship hulks don't disappear until there are too many hulks on the map. I looked in the json configurations but didn't find anything relevant, then I dug through the API to see if there is something that controls this, specifically in CombatEngineAPI, but didn't find anything.

Then what I did is hijack a mod that had a plugin that extends BaseEveryFrameCombatPlugin which iterates over hulks, and then I tried various things in the advance method :
  • ship.setHitpoints(10000) : I thought maybe hulks have decaying hull ? But no, this doesn't work.
  • ship.setHulk(false) : Immediately makes the hulk disappear.
  • ship.setTimeDeployed(0) : Doesn't work.

Am I missing anything ?

Hi - ahh, sorry, this looks like it won't work. There's a "sinceVisible" variable that tracks how long it was since the hulk was near the visible area of the battlefield, and the despawning is based on that. And there are no getters/setters for this variable.

Update: I have solved my silly question. After some tests, I found that if I add another condition to the tomas mission macario greeting that !$global.TomasMissionCompleted, the FireAll actually worked. And so FireAll PopulateOptions should be the proper way to do this, it's just I need to set up the greeting conditions correctly so that it would not get overrided by the vanilla macario greeting rule.

Just a quick note, if you're not aware already: if you need one rule to have higher priority, you can append " score:1000" (or some other number) to one of its conditions. Normally a rule's "score" is the number of conditions it has, and the rule with the highest score gets picked. Though, this only applies for FireBest - FireAll fires all the matching rules, regardless of their scores.



how does PlanetAPI.setSecondLight() work?
I'm setting it in an EveryFrameScript with runWhilePaused returning true but it only ever actually works while the game is paused, if I unpause the planet goes back to being unlit.

Hmm - FusionLampEntityPlugin (which is in the api source) uses this and it works. I'm not seeing anything wrong with your code offhand, though, so I'm not sure what the difference is.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #10529 on: March 04, 2024, 10:27:07 AM »

Hmm - FusionLampEntityPlugin (which is in the api source) uses this and it works. I'm not seeing anything wrong with your code offhand, though, so I'm not sure what the difference is.

yeah, I looked there to see how it was done in the first place.
my only guess is that the system having no primary star does something funky to it, but I've given the SectorEntityToken that I got from initNonStarCenter() the AMBIENT_LS tag & that lighting works fine. (and the whole "only works while paused" thing makes no sense if that's the issue)

EDIT : moved the relevant code into a custom campaign entity plugin & it works fine now, huh.
« Last Edit: March 05, 2024, 07:10:25 AM by Ruddygreat »
Logged
Pages: 1 ... 700 701 [702] 703 704 ... 710