Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 465 466 [467] 468 469 ... 710

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

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 231
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6990 on: January 17, 2021, 03:42:30 PM »

Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6991 on: January 18, 2021, 12:13:26 PM »

Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Check intel manager - if you add intel it will show up immediately, and if you queue it will show up once within comms array range. This interface also has the method you are after.

https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/comm/IntelManagerAPI.html
« Last Edit: January 18, 2021, 12:15:17 PM by Jaghaimo »
Logged

NikoTheGuyDude

  • Commander
  • ***
  • Posts: 231
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6992 on: January 18, 2021, 12:49:19 PM »

Where, in the files/code, is it decided which intel is restricted to comm relays? I know that "boolean isPlayerInRangeOfCommRelay()" is a thing, I just don't know where in the code specific pieces of intel are bound by this.
Check intel manager - if you add intel it will show up immediately, and if you queue it will show up once within comms array range. This interface also has the method you are after.

https://fractalsoftworks.com/starfarer.api/com/fs/starfarer/api/campaign/comm/IntelManagerAPI.html

Thanks! I had already found that interface, but I wasn't entirely clear on the mechanics of queueing.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4681
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6993 on: January 23, 2021, 02:35:03 AM »

Why does farming continue to produce food after I call removeCondition, reapplyConditions, reapplyIndustries on the market?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6994 on: January 23, 2021, 10:20:24 AM »

Hmm - this is a bit tricky. Basically the "supply" in BaseIndustry needs to be persistent (and not reset by, say, reapplying the industry) because things like market conditions need to be able to affect it. Otherwise you could have a market condition affecting it, then industries getting reapplied and this discarding the effect of the market condition. That's why e.g. just blanketly having supply.clear() in the industry's unapply() method wouldn't work.

I don't remember all the details here, just that there are a number of potential interactions/combinations and it's, again, tricky.

It looks like "removing a ResourceDepositsCondition from a market" is not a directly supported use case. However, you could probably iterate over the results of industry.getAllSupply() and clear out the modifiers for getQuantity(), after removing a condition, and I think that'd do the trick. Something like:

Code
for (MutableCommodityQuantity q : industry.getAllSupply()) {
q.getQuantity().clear();
}

Provided the getAllSupply() method is in the current release, that is.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6995 on: January 30, 2021, 11:13:54 PM »

You know those interactions where the AIs hail you and the entire game pauses. Is it possible for an interaction to not pause the game? I'd like to make a mini-game where the player can play blackjack and poker with themselves when waiting for those long-distance bounty trips.

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 #6996 on: January 31, 2021, 06:53:22 AM »

Is the BaseSpecialItemPlugin only inited each time I open the cargo dialog?
Logged
My mods


IonDragonX

  • Admiral
  • *****
  • Posts: 816
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6997 on: January 31, 2021, 07:43:10 AM »

Hello, a follow-up to the hyperspace system hiding:
The script
Code
    
@Override
    public void onNewGameAfterProcGen() {
        for (SectorEntityToken token : Global.getSector().getHyperspace().getAllEntities()) {
            token.setDiscoverable(true);
            token.setSensorProfile(2000f);
        }
    }

Here's a plugin that I've been working on:

Spoiler
package data.scripts.plugins;

import com.fs.starfarer.api.BaseModPlugin;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;


public class bgo_ModPlugin extends BaseModPlugin {
   private static float Paxis = 0.25f; // major & minor axis of ellipse is default >> 50% << of that of the field - then div by 2 to change axis to >> semi-axis << - already simplified
   private static float ASqu = (Paxis * 164000f * Paxis * 164000f); // is the a^2 in the ellipse formula -  width of sector field factored by P and then squared
   private static float BSqu = (Paxis * 104000f * Paxis * 104000f); // is the b^2 in the ellipse formula -  height of sector field factored by P and then squared

@Override
   public void onNewGameAfterProcGen() {
// The formula of an ellipse that has a horizontal major axis
// (x^2/a^2) + (y^2/b^2) = 1
// granted that (x,y) are coordinates on the line; a is the major semi-axis and b is the minor semi-axis
// semi-axis means half the axis
// Vanilla values for sector field:
// sectorWidth:164000
// sectorHeight:104000
// as Paxis is increased, the ellipse gets bigger, revealing more stars.
   for (SectorEntityToken token : Global.getSector().getHyperspace().getAllEntities()) {
      if ((token instanceof JumpPointAPI) && ((JumpPointAPI) token).isStarAnchor() && ((JumpPointAPI) token).getDestinationVisualEntity().getStarSystem().isProcgen()) {
//         float XSqu; // is the x^2 in the ellipse formula -  X coordinate squared
//         float YSqu; // is the y^2 in the ellipse formula -  Y coordinate squared
//         ((JumpPointAPI)token).getLocation((float) XSqu,(float) YSqu);
//         XSqu = XSqu(XSqu);
//         YSqu = YSqu(YSqu);
//         if (((XSqu/ASqu) + (YSqu/BSqu)) > 1) {
            token.setDiscoverable(true);
            token.setSensorProfile(2000f); //            token.setProcgen(false);
//          }
      }
   }
}
}
[close]

What I want to know is : How can I get the coordinates of the system to compare it to the (0,0) center? I tried SectorEntityToken but it only has a Vector value.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6998 on: January 31, 2021, 08:53:13 AM »

You know those interactions where the AIs hail you and the entire game pauses. Is it possible for an interaction to not pause the game? I'd like to make a mini-game where the player can play blackjack and poker with themselves when waiting for those long-distance bounty trips.

I don't know - sounds like a mod thing? But, to answer your question: you can unpause the game, but I don't think it's a good idea. Consider cases where a dialog might need to pop up during travel (such as, say, from encountering a fleet). Those sorts of complications would not be possible to handle.


Is the BaseSpecialItemPlugin only inited each time I open the cargo dialog?

I think it's inited when the cargo stack is created. At least, looking at the code it's called from the cargo stack constructor. Something else to note is the plugin is transient, meaning it will not be saved to the savefile, and will instead be re-inited when the game is loaded.

What I want to know is : How can I get the coordinates of the system to compare it to the (0,0) center? I tried SectorEntityToken but it only has a Vector value.

Hmm, I don't understand the question - a Vector2f *is* a coordinate pair. It has fields x and y.
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 #6999 on: January 31, 2021, 09:17:16 AM »

I think it's inited when the cargo stack is created. At least, looking at the code it's called from the cargo stack constructor. Something else to note is the plugin is transient, meaning it will not be saved to the savefile, and will instead be re-inited when the game is loaded.
Okay, I think I understood. BTW, who to get the time multiplier in the campaign(The speed up after pressing shift)? I use EveryFrameScript which would run while paused as a timer for some UI elements, but it seems that the amount is affected by the time multiplier or something else.

Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7000 on: January 31, 2021, 09:50:33 AM »

Hmm - looking at the code, I don't think that's directly possible. The advance() method just gets called the number of times the speedup multiplier is.

A way to kind of get around this might be to use SectorAPI.getCampaignUI().getSharedFader() - that'll be .isFadedIn() every real-world second, regardless of the campaign speedup.
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 #7001 on: January 31, 2021, 04:27:12 PM »

Hmm - looking at the code, I don't think that's directly possible. The advance() method just gets called the number of times the speedup multiplier is.

A way to kind of get around this might be to use SectorAPI.getCampaignUI().getSharedFader() - that'll be .isFadedIn() every real-world second, regardless of the campaign speedup.
Fine, I use System.nanoTime to get the elapsed time now.
« Last Edit: January 31, 2021, 04:32:32 PM by Originem »
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7002 on: January 31, 2021, 06:14:10 PM »

Fine, I use System.nanoTime to get the elapsed time now.

Oh yeah! Forgot that it doesn't have to use something from the API, hah - that's a completely legitimate way of doing it.
Logged

mendonca

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1159
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7003 on: February 01, 2021, 03:13:09 AM »



Hey I'm a bit stuck as to why my rules don't seem to be registering a particular memory flag. Can anyone give some clues for debugging this?

I'm happy with formatting, have tried changing variable name, tried deleting the rules which are overriding. Basically, as far as I can tell, I've done the simple checks a few times each, and ran through on the Discord with Nicke to try and make sure I was being as sensible as I can be,

The implementation I am using is the same in another part of my mod, and it works fine there, for different custom fleet types (which get the flag assigned in the same way, using getMemoryWithoutUpdate().set($tag, true) etc. )

Are there certain things I need to be aware of to avoid that might make a memory flag become invisible or something?
Logged


"I'm doing it, I'm making them purple! No one can stop me!"

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #7004 on: February 01, 2021, 10:11:31 AM »

I think you just need to use the flags like so:

$entity.XYZJnkPirateExplorers

Etc. In OpenCommLink (and the rest of the conversation), the "local" memory becomes the person's memory, and the formerly-local entity memory is shunted off to the $entity. context. That's probably the single trickiest bit about rules, keeping that in mind when say adding a conversation - the same basic rule in BeginFleetEncounter (entity is in local context) and OpenCommLink (entity is in $entity, person is local) will use the variables without/with the prefix.

Edit:
Also, I'd add a score to that condition, like so:
$entity.XYZJnkPirateExplorers score:1000

Just to make sure that this "special" interaction takes precedence over, say, the standard greeting text, which may have the same number (or more) conditions. Rules with more conditions get higher priority (i.e. the more specific the rule, the higher priority it has), but the " score" affix can change the weight of each condition. The default weight is 1 score point per condition.
« Last Edit: February 01, 2021, 10:13:34 AM by Alex »
Logged
Pages: 1 ... 465 466 [467] 468 469 ... 710