Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 430 431 [432] 433 434 ... 710

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

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6465 on: May 28, 2020, 03:23:08 PM »

Ah - I'd suggest trying hardcoded highlights to try to narrow down the issue. Also, you may need to set a highlight color, and it may be sensitive to the order (i.e. you might have to do set color, then highlight, or vice versa), but I don't 100% remember off the top of my head. Basically what I'm suggesting is get *any* highlight working and then go from there to try to identify what's making your case not work.

Thanks! :) I'll narrow it down- hopefully tomorrow at some point.

Not 100% sure yet, but it looks like it wasn't working because the string sent into the highlight method needs to be surrounded by spaces (maybe punctuation is ok? Haven't tested that yet, actually) in the paragraph it is trying to highlight. So, it looks like the lack of separator removal logic was part of the problem. It still isn't working when the separators are removed, but I got a success case by hardcoding "and" and it was highlighted. So hmm. I'll look at this more tonight.

For instance, sending in "credit" will work with: "Not a credit more!" but not: "Give me your credits!"
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6466 on: May 28, 2020, 04:43:48 PM »

Is it possible to manually (I mean via script call or similar) kill crew during combat and have those losses appear in the results screen afterwards? And if so, can it also be done with Marines? (And just out of curiosity, other cargo items)
Logged

tomatopaste

  • Captain
  • ****
  • Posts: 306
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6467 on: May 28, 2020, 04:47:15 PM »

Is it possible to manually (I mean via script call or similar) kill crew during combat and have those losses appear in the results screen afterwards? And if so, can it also be done with Marines? (And just out of curiosity, other cargo items)
I believe this can be done through rules modifications, you can get the lowest hull level of a ship through ShipAPI via plugin, and then have a rules hook that fires at the end of combat, with marine losses subtracted and the player notified similarly to crew. Most rules scripts are in api impl, so you should find what you're looking for.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6468 on: May 28, 2020, 05:15:48 PM »

I believe this can be done through rules modifications, you can get the lowest hull level of a ship through ShipAPI via plugin, and then have a rules hook that fires at the end of combat, with marine losses subtracted and the player notified similarly to crew. Most rules scripts are in api impl, so you should find what you're looking for.
Hi, thanks for the quick reply!

However, I was thinking of something that can give me finer control of how many gets killed. For example, if you shoot this gun, 5 crew immediately get killed, or if you get hit by this projectile, 5 marines get killed. Something like that. If I read your suggestion right, the losses incurred would be calculated relative to the ship hull/crew losses formula...
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6469 on: May 28, 2020, 05:42:52 PM »

Not 100% sure yet, but it looks like it wasn't working because the string sent into the highlight method needs to be surrounded by spaces (maybe punctuation is ok? Haven't tested that yet, actually) in the paragraph it is trying to highlight. So, it looks like the lack of separator removal logic was part of the problem. It still isn't working when the separators are removed, but I got a success case by hardcoding "and" and it was highlighted. So hmm. I'll look at this more tonight.

For instance, sending in "credit" will work with: "Not a credit more!" but not: "Give me your credits!"

Ah - right, yeah, highlighting requires whitespace/punctuation boundaries. Otherwise it could be a real mess highlighting things like, uhh, "the accredited institution pays you X credits" and so on. I mean, one could always go the "add markup to text" route, but that's more of a pain.

However, I was thinking of something that can give me finer control of how many gets killed. For example, if you shoot this gun, 5 crew immediately get killed, or if you get hit by this projectile, 5 marines get killed. Something like that. If I read your suggestion right, the losses incurred would be calculated relative to the ship hull/crew losses formula...

I don't think you could do that seamlessly. Best you could do, I think, would be to note these losses, and then apply them after the combat, separately, and have an intel item pop up.

(Or, I mean, you *could* provide a custom implementation of FleetEncounterContext or FleetInteractionDialogPluginImpl, but that'd I think make your mod incompatible with Nexerlein and/or any other mod that does that.)
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6470 on: May 28, 2020, 06:40:26 PM »

Ah - right, yeah, highlighting requires whitespace/punctuation boundaries. Otherwise it could be a real mess highlighting things like, uhh, "the accredited institution pays you X credits" and so on. I mean, one could always go the "add markup to text" route, but that's more of a pain.

Oh right yeah that makes sense! I have it *mostly* working now.

*EDIT* Ok now I really don't understand what's going on... see details below. I seem to be getting inconsistent results from the highlight method. Specifically look at "credit" in the second log and screenshot- "credits" gets the highlight... minus the "s" which debunks the earlier logic. I originally thought credit came before credits but looking again that's incorrect. Maybe it is only performing the highlight on the first instance? *See below post* The log verifies the logic to pass the correct data into the highlight method is working as intended. I also added a code example of where the logging happens for reference.

Speaking of "X credits", when the replacement token is storing an int and replaces X with the correct amount of credits, passing that amount (as a string) into the highlight method doesn't work for some reason. I have tested other replacement tokens like $HeOrShe, $personName, etc- at both the start of the line and between other logic tokens and all of that works fine. This leads me to believe that the issue is that the replacement token points to an int. *See below post*

Any way to handle this that you can think of? The way the token parser works is that it compiles the list of highlights found into a List (from a comma separated string) and then iterates through the list and passes each highlight into the method. The string it parses through is the returned string from:
Code
responseDialogue = Misc.getStringWithTokenReplacement(responseDialogue, dialog.getInteractionTarget(), memoryMap);

I set up some logging and got:

Log:
Spoiler
68571 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Using default dialogue response for: commodityRequestSuccessHaveToPay
68571 [Thread-4] INFO  util.FDialogue_cellDataManager  - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 1
68571 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: 3981,and,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: 3981
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: and
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: Four Cross,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: Four Cross
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: She,
68572 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: She
[close]
Spoiler
425639 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Faction id: hegemony - was found in FleetDialogue_factionText.csv, but no valid entry was found for: commodityRequestSuccessHaveToPay
425639 [Thread-4] INFO  factions.FDialogue_factionTextLoader  - Using default dialogue response for: commodityRequestSuccessHaveToPay
425640 [Thread-4] INFO  util.FDialogue_cellDataManager  - Multiple dialogue options detected in cell. 2 total options detected. Selected option: 2
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: 4208,credit,
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: 4208
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: credit
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Highlights detected in dialogue response: lieutenant,and,she,
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: lieutenant
425640 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: and
425641 [Thread-4] INFO  util.FDialogueTokenParser  - Attempting to highlight: she
[close]

Game screenshots of results:
Spoiler


[close]

Original cell string:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL$AidRequest_estCost$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHL$personName$ENDHL has you in a tight spot. $NEWLINE$STARTHL$HeOrShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL$AidRequest_estCost$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHL$personRank$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHL$heOrShe$ENDHL has no real reason to help you in the first place.
[close]

Spoiler
Code
    private static void addDialogueHighlights(String highlights, InteractionDialogAPI dialog) {
        if (highlights != null) {
            LOG.info("Highlights detected in dialogue response: " + highlights);
            List<String> highlightList = Arrays.asList(highlights.split(","));
            for (int i = 0; i < highlightList.size(); i++) {
                LOG.info("Attempting to highlight: " + highlightList.get(i));
                dialog.getTextPanel().highlightInLastPara(Misc.getHighlightColor(), highlightList.get(i));
            }
        }
    }
[close]

What I assume the returned string looks like:
Spoiler
"I suppose I could help you, but don't think I'm dumb enough to simply give it away... it'll cost you $STARTHL3981$ENDHL credits for my overhead costs $STARTHLand$ENDHL inconvenience."$NEWLINEYou know that the market cost of what you are asking for is probably lower than what you are currently being forced to pay, but $STARTHLFour Cross$ENDHL has you in a tight spot. $NEWLINE$STARTHLShe$ENDHL is doing you a favor by helping you, and a convenience markup is common in such situations anyway.OR"Sure, but you're crazy to think I'd just give you something for free. $STARTHL3981$ENDHL credits gets you what you need. Not a $STARTHLcredit$ENDHL less, either!"$NEWLINEThis arrangement is clearly benefiting the $STARTHLcaptain$ENDHL since the market cost of resupplying your fleet might generally be much lower, but your reputation is average $STARTHLand$ENDHL $STARTHLShe$ENDHL has no real reason to help you in the first place.
[close]
« Last Edit: May 29, 2020, 07:40:40 PM by Morrokain »
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6471 on: May 28, 2020, 06:53:14 PM »

I don't think you could do that seamlessly. Best you could do, I think, would be to note these losses, and then apply them after the combat, separately, and have an intel item pop up.
Hmm, I see. That'll work, I think! Maybe I could also just add some floating text during the combat so the player knows what happened and when. Thank you!
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6472 on: May 29, 2020, 07:33:12 PM »

Ahhhh OK, I think I have this sorted now.

The reason I was confused was that the highlight method overwrites the paragraph each time it is called. Because of this, the other highlights I was specifying would only get captured if they were contained in another paragraph from addParagraph(). (This sometimes happens because when I parse a new line I call addParagraph() each time then call the highlight method before adding another new paragraph for the next dialogue component.) That is why it seemed like it highlighted a random amount of strings... (Some dialogue choices have multiple paragraphs and some don't.) Also, the credit amount issue that I was theorizing was somehow related to the integer from replacement was all wrong. :P It was just ironically being overridden by the next highlight each time I tested it despite changing the highlights multiple times. Even when I hardcoded it for a test I called the method twice... so the credit portion just happened to be overridden in every instance. Ha!  ::)

The actual way to specify additional highlights in the same paragraph is to add additional string parameters to:
Code
                dialog.getTextPanel().highlightInLastPara();

Well... that complicates things since the number of highlights per paragraph ideally would be variable. Unless there is a way to dynamically change method signatures and add parameters based upon a list size (I don't know I've never tried) I will just have to set a maximum number of highlights per paragraph and create a switch based upon the List size to determine which method signature to use if all else fails.

However, I also messed around with:

Code
                Highlights highlightData = new Highlights();
                highlightData.setText(highlightList.get(i));
                highlightData.setColors(Misc.getHighlightColor());
                dialog.getTextPanel().setHighlightsInLastPara(highlightData);

I'm going to try the append() method for the HighLights class to see if I can get dynamic highlights that way using a List. If not, I'll use the other implementation.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4681
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6473 on: May 30, 2020, 09:00:03 AM »

TextPanelAPI.addPara returns a LabelAPI. You can then call LabelAPI.setHighlight and LabelAPI.setHighlightColors, much easier that way.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6474 on: May 30, 2020, 02:51:59 PM »

TextPanelAPI.addPara returns a LabelAPI. You can then call LabelAPI.setHighlight and LabelAPI.setHighlightColors, much easier that way.

Thanks for the info!  :)

The main difference I see between the two ways of doing that is the LabelAPI allows for index based highlights and dehighlights. That may definitely come in handy and I'll keep it in the back of my mind.

It doesn't solve the original problem though- because adding highlights from LabelAPI's general highlight method still requires multiple substrings as additional parameters rather than accepting a List or Array.

However:

Dynamic highlights from parsing the cell can be done using:

Code
        if (highlights != null) {
            LOG.info("Highlights detected in dialogue response: " + highlights);
            List<String> highlightList = Arrays.asList(highlights.split(","));
            Highlights highlightData = new Highlights();
            for (int i = 0; i < highlightList.size(); i++) {
                LOG.info("Attempting to highlight: " + highlightList.get(i));
                highlightData.append(highlightList.get(i), Misc.getHighlightColor());
            }
            dialog.getTextPanel().setHighlightsInLastPara(highlightData);
        }

That will highlight every parsed highlight wrapper string in the paragraph. Unless I'm missing something (very possible haha) I think this might be the only way to add highlights dynamically.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6475 on: May 30, 2020, 03:12:03 PM »

The varargs thing - where you can pass in multiple strings as additional parameters - also accepts an array.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6476 on: May 30, 2020, 04:05:10 PM »

The varargs thing - where you can pass in multiple strings as additional parameters - also accepts an array.

Ah ok! I was trying a List. I also tried List.toArray() which probably doesn't work because it returns Object[] instead of String[].

What you need to pass in is String[] list = string.split(","); I haven't confirmed it works yet, but at least IntelliJ doesn't gripe at me about it like it does the other two.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6477 on: May 30, 2020, 04:32:10 PM »

You can also do list.toArray(new String[0]) which returns a "String []"
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6478 on: May 30, 2020, 04:54:19 PM »

You can also do list.toArray(new String[0]) which returns a "String []"

Can this same technique be used to set multiple highlight colors in the same paragraph using LabelAPI.setHighlightColors(Color... colors)? (Don't have time to test it at the moment)

So I could set a color option per highlight wrapper and then pass in the colors in the same order as the highlight list?

Like:

Code
Color[] colors = list.toArray(new Color[0]);
LabelAPI.setHighlightColors(colors);
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24111
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6479 on: May 30, 2020, 05:09:13 PM »

Yep!
Logged
Pages: 1 ... 430 431 [432] 433 434 ... 710