Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 342 343 [344] 345 346 ... 710

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

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5145 on: September 20, 2019, 02:43:51 PM »

When i use IntervalUtil(float minInterval, float maxInterval) to make timers, would the interval for one second be 1.0f? Also if i set min and max interval the same and call the check every frame is  it granted that it will not miss the interval or should i put a bit of space between min and max?
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5146 on: September 20, 2019, 02:53:09 PM »

That depends on what you pass in to IntervalUtil.advance(). An interval of 1.0f will elapse after the sum total of the "amount" parameter to that method reaches 1.0f. So if you pass in seconds, it'll be seconds, if you pass in days, it'll be days.

It's safe to have min and max be the same value, but in that case it'd be simpler to just track an "elapsed" time directly. Something like:

elapsed += amount;
if (elapsed >= 1f) {
  elapsed -= 1f;
  // do thing
}

The point of IntervalUtil is to randomize when something happens, often to help avoid certain tasks syncing up and hitting the same frame too much. If you're not using it to randomize, it'll work, but it's a bit overkill.

(You can view the source of IntervalUtil, btw; it's in the api.zip.)
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5147 on: September 20, 2019, 02:57:17 PM »

 Thanks Alex, it is clear now.
Logged
Check out my ships

SomeDegenerate

  • Ensign
  • *
  • Posts: 15
  • Credit to TerminalMontage on YouTube for the PfP
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5148 on: September 20, 2019, 03:32:41 PM »

Right, so I've managed to muck something up. As I try to reference getEntityById([RelayID]) from LocationAPI, I get an error that the method getEntityById() is undefined for type [MyClassName]. Then when I try to refer to it statically via LocationAPI.getEntityById(), I get a "cannot make a static reference to a non-static method" error - so I'm at a bit of a loss. I've had no trouble importing methods from other packages - though upon second look it seems that all the methods I've needed have been a part of the package I'm already operating in.

For reference, my class extends BaseIndustry as I'm trying to create a new Planetary Structure. I can paste my code here if that helps.

Thanks!


Never mind. I forgot Java was Object Oriented there for a second. Solved the problem by, y'know, creating a LocationAPI variable from which I could call the getEntityById function.

It's been a long day, lol.
« Last Edit: September 20, 2019, 03:43:29 PM by SomeDegenerate »
Logged
Roses are red, violets are blue. I'm complete garbage, how about you?

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5149 on: September 20, 2019, 06:03:09 PM »

How do i turn off all weapons from a ship or module for X amount of time?
Do disable() breaks the weapon or just turns it off? and what do i use to bring it back? I can't find any enable() method.
Logged
Check out my ships

Bad_Idea

  • Ensign
  • *
  • Posts: 17
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5150 on: September 21, 2019, 03:08:36 PM »

Previous solved question:
Spoiler
Would it be possible to directly set the .skin of a ship?

To outline the idea i want to be able to, by installing a hullmod on a ship (the central "core"), enable or disable weapon slots on the ship in question. I know a way of enabling or disabling weapon slots is by using the removeWeaponSlots in a .skin file which nicely allows you to keep a weapon slot active only for a certain .skin. The problem here however is that i don't see any good ways (if any at all) to directly interact with these parts of the ship in the API. I was looking for how the "restore ship" function in the hangar did its job but was unable to find it anywhere in the API, which i found a little strange.

So, in essence: Is there any way of setting the skin of a ship with the intent to enable or disable weapon slots? (In the refit view)
[close]

New question:
Is there any good way to, in the refit screen, refund or return a weapon in a specific slot? Changing the hull of a ship when weapons are mounted leads to some funny things happening (namely crashes) and i'd love to be able to return a weapon to the player or the store without costing the player extra money/giving them free weapons. I've been looking into both the stripWeapons function and the player market transaction APIs for some ideas on what to do, but both of these are rabbit holes so deep i hardly know where to begin.

In addition to this question i'm wondering if there is a way of forcing the refit screen to update, such as it does when you restore a ship. I thought maybe i could simulate an R keypress which would reopen the refit screen, but this does not seem to be working.
« Last Edit: September 22, 2019, 06:25:09 AM by Bad_Idea »
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5151 on: September 21, 2019, 04:31:08 PM »

Could someone guide me through adding a custom start?
I'd tried copying and modifying one of Vayra's to get used to it all, but when I try to launch it I get:
Code
Fatal: java.lang.RuntimeEception: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd

Cause: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd
EDIT: Attached the whole thing, if that helps.

[attachment deleted by admin]

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5152 on: September 21, 2019, 06:49:32 PM »

I want to make a Custom Defensive Ship System that will be a strong EMP, similar to the vanilla EMP system, but can be disabled and enabled at anytime like a shield.

In the wiki it says:

Quote
Alternate defense systems

It is possible to create a custom shield replacement (right-click activated) by extending the functionality of the phase cloak implementation. Phase cloak works by setting the Ship Data CSV shield type field to "PHASE" and designating the ship system ID "phasecloak" in the defense id field. This causes the ship system phasecloak to be activated on right-click. Different, custom ship systems can also be designated in the Ship Data CSV defense id field instead of phasecloak
This explains what to put in the "defense id" field, but what do i put in "shield type" field?

Quote
Special consideration needs to be taken for the AI for the ship system as it is not treated as the ship system by parts of the engine. For example an AI that activates the ship system will activate whatever is set as that ship's system, as opposed to the ship system which is replacing the shield
So i don't need to design a custom AI and the ship will activate the system in any situation it would activate a shield? Sounds good for what i have in mind.
Logged
Check out my ships

Histidine

  • Admiral
  • *****
  • Posts: 4682
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5153 on: September 21, 2019, 07:10:50 PM »

Could someone guide me through adding a custom start?
I'd tried copying and modifying one of Vayra's to get used to it all, but when I try to launch it I get:
Code
Fatal: java.lang.RuntimeEception: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd

Cause: Command [NGCYunruStrangerStartScript] not found in packages:
com.fs.starfarer.api.impl.campaign.rulecmd
com.fs.starfarer.api.impl.campaign.rulecmd.salvage
com.fs.starfarer.api.impl.campaign.rulecmd.newgame
com.fs.starfarer.api.impl.campaign.rulecmd.missions
org.lazywizard.console.rulecmd
Typo in the NGCYunruStrangerStartScript class name: "Stanger"

In the wiki it says:

Quote
Alternate defense systems

It is possible to create a custom shield replacement (right-click activated) by extending the functionality of the phase cloak implementation. Phase cloak works by setting the Ship Data CSV shield type field to "PHASE" and designating the ship system ID "phasecloak" in the defense id field. This causes the ship system phasecloak to be activated on right-click. Different, custom ship systems can also be designated in the Ship Data CSV defense id field instead of phasecloak
This explains what to put in the "defense id" field, but what do i put in "shield type" field?
It tells you to enter PHASE as shield type
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5154 on: September 21, 2019, 07:15:38 PM »

Typo in the NGCYunruStrangerStartScript class name: "Stanger"
Feel so dumb.
Update: Fixed typo, but still get the error.

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5155 on: September 21, 2019, 08:28:21 PM »

Is DO_NOT_CONSERVE still an active weapon tag for missiles? And what, specifically, does it do when combined with STRIKE?
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5156 on: September 22, 2019, 06:52:24 AM »


It tells you to enter PHASE as shield type
Ok, thanks
Logged
Check out my ships

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5157 on: September 22, 2019, 10:14:11 AM »

How do i turn off all weapons from a ship or module for X amount of time?
Do disable() breaks the weapon or just turns it off? and what do i use to bring it back? I can't find any enable() method.

I think repair() would do it, as far as turning it back on. And, yeah, disable "breaks" it the way combat damage would.


New question:
Is there any good way to, in the refit screen, refund or return a weapon in a specific slot? Changing the hull of a ship when weapons are mounted leads to some funny things happening (namely crashes) and i'd love to be able to return a weapon to the player or the store without costing the player extra money/giving them free weapons. I've been looking into both the stripWeapons function and the player market transaction APIs for some ideas on what to do, but both of these are rabbit holes so deep i hardly know where to begin.

In addition to this question i'm wondering if there is a way of forcing the refit screen to update, such as it does when you restore a ship. I thought maybe i could simulate an R keypress which would reopen the refit screen, but this does not seem to be working.

I don't think so? At least, nothing that I can think of in the API. There may be some creative workarounds, but that'd be more a question for someone other than me.

Is DO_NOT_CONSERVE still an active weapon tag for missiles? And what, specifically, does it do when combined with STRIKE?

Pretty sure it is, yeah. STRIKE would make it not be used vs frigates and... whatever else it generally goes. DO_NOT_CONSERVE would just make it fire regardless of how much ammo is left, i.e. it wouldn't save HE missiles for when the target is vulnerable.
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5158 on: September 22, 2019, 10:25:44 AM »

Here's the content of the thing it can't find, if that helps:
Code
package com.fs.starfarer.api.impl.campaign.rulecmd;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.Script;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.campaign.RepLevel;
import com.fs.starfarer.api.campaign.rules.MemKeys;
import com.fs.starfarer.api.campaign.rules.MemoryAPI;
import com.fs.starfarer.api.characters.CharacterCreationData;
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.shared.SharedData;
import com.fs.starfarer.api.util.Misc;
import java.util.List;
import java.util.Map;

// YoU kNow, Really i don't Understand what i'm doing

public class NGCYunruStrangerStartScript extends BaseCommandPlugin {

    @Override
    public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {
        if (dialog == null) {
            return false;
        }
        CharacterCreationData data = (CharacterCreationData) memoryMap.get(MemKeys.LOCAL).get("$characterData");

        data.addScript(new Script() {
            @Override
            public void run() {
                String pirateId = Factions.PIRATES;
                String ludicID = Factions.LUDIC_PATH;
                FactionAPI player = Global.getSector().getFaction(Factions.PLAYER);
                player.setRelationship(pirateId, RepLevel.SUSPICIOUS);
                player.setRelationship(ludicId, RepLevel.SUSPICIOUS);
                for (FactionAPI other : Global.getSector().getAllFactions()) {
                    if (other.getRelationship(player)>-1) {
                        player.setRelationship(other.getId(), Rep.Level.SUSPICIOUS);
                    }
                }
            }
        });
        return true;
    }
}
(And yes, I noticed I have 1 too few d's on Luddic >.< )

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5159 on: September 22, 2019, 11:49:59 AM »

Pretty sure it is, yeah. STRIKE would make it not be used vs frigates and... whatever else it generally goes. DO_NOT_CONSERVE would just make it fire regardless of how much ammo is left, i.e. it wouldn't save HE missiles for when the target is vulnerable.

Hm, ok that's what I thought.

I am having issues with the AI being very unwilling to use Reapers in particular. To clarify why this doesn't make sense to me: Reapers regenerate and do not cost flux to fire so they are completely expendable and should always be fired when in range. I have a phase battleship, in particular, armed with the ability to fire 8 Reapers at once.

When it is given an "Eliminate" command on another enemy capital, the AI doesn't ever fire the Reapers even though at least 4 of them are turreted.

When I personally fly the battleship, I get within range and unleash all torpedoes. The enemy capital DIES. In the AI hands, if the battleship wins even at all it often has less than a third of its hull remaining.

Any ideas on what I am doing wrong?
Logged
Pages: 1 ... 342 343 [344] 345 346 ... 710