Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 322 323 [324] 325 326 ... 467

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

Vayra

  • Admiral
  • *****
  • Posts: 581
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4845 on: August 22, 2019, 10:10:35 PM »

Whoops, got one more.

Code: java
            DerelictShipEntityPlugin plugin = (DerelictShipEntityPlugin) entity.getCustomPlugin();
            PerShipData shipData = plugin.getData().ship;
            this.variant = shipData.variant;
            if (this.variant == null) {
                this.variant = Global.getSettings().getVariant(shipData.variantId);
            }
            shipData.variantId = null;
            this.variant = this.variant.clone();
So this creates a ShipVariantAPI. All good so far. Note the shipData.variantId = null; because it looks like ShipRecoverySpecial prefers variantId over variant, heh.

This, in ShipRecoverySpecial
Code: java
		FleetMemberAPI member = null;
if (shipData.variantId != null) {
member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, shipData.variantId);
} else {
member = Global.getFactory().createFleetMember(FleetMemberType.SHIP, shipData.variant);
}
creates a FleetMemberAPI, and sets its variant to that ShipVariantAPI as long as it doesn't have a .variantId. Am I right in assuming the ShipVariantAPI we created with .clone() above is the same instance as this new FleetMemberAPI will have, and will be unique to that FleetMemberAPI since it's a clone created in the process of generating it, and I can therefore store data in the hullmod with the ShipVariantAPI as a key? Or does .createFleetMember() clone the variant again?
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Sundog

  • Admiral
  • *****
  • Posts: 1154
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4846 on: August 22, 2019, 11:06:01 PM »

Is it possible Im importing the wrong things?
It looks to me like you've got all your bases covered as far as imports are concerned. My guess at this point is that there's something wrong with your hull_mods.csv file. If you want to zip up your mod and send it to me I'd be happy to take a look.

@Varya: This stretches the limits of my knowledge a bit (hopefully Alex will correct me if I'm wrong), but...
Looking through decompiled code of createFleetMember, I see that it assigns the instance of the variant you pass it, so it looks to me like it should be the same key. Of course, it's always possible that it's changed later. If you want to make sure, you should be able to check for instance equality like this:
Code
if(if(member.getVariant() == shipData.variant)) {
    // Notify you somehow
}
clone() creates a new instance, which is the method of comparison used by HashMaps for objects that don't override equals() and hashCode(), so each clone should work as a unique key, even if they all have the same values.

bowman

  • Lieutenant
  • **
  • Posts: 64
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4847 on: August 23, 2019, 12:31:15 AM »

So, I did a search but.. not much came up. Hopefully I didn't just miss a post entirely.

Is there a way to check if a ship is phased? This is a built-in hullmod so it isn't an issue between "does the ship have phase or shield", instead it's simply "is it currently using its phase cloak". Without this if-statement the rest of the code seems to work fine but, with it, it doesn't activate even when phased. Are phase systems not considered shields for the ShieldAPI and thus returning null? Is there a different API I should be using? Maybe I'm just using the API wrong?(I really don't know java so it's probably the case)
I saw a phasecloakstats but that seemed like it was the phase jump ship system or something else.

Code
public void advanceInCombat (ShipAPI ship, float amount) {
ShieldAPI cloak = ship.getShield();

if (cloak != null && cloak.isOn()) {

//lines im ommitting because they're otherwise functional and it would just take up forumspace
}
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1154
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4848 on: August 23, 2019, 01:01:14 AM »

Are phase systems not considered shields for the ShieldAPI and thus returning null?
You guessed it.
Code
ship.getPhaseCloak().isActive()

bowman

  • Lieutenant
  • **
  • Posts: 64
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4849 on: August 23, 2019, 01:23:00 AM »

@Sundog that did it, thank you :)

now I just need to sprite a new ship for it..
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1154
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4850 on: August 23, 2019, 01:40:26 AM »

No problem! I look forward to seeing what you come up with  :)

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4851 on: August 23, 2019, 02:49:56 AM »

How does economyIntervalnGameDays affect patrols? I noticed that it may have something to do with battles lost.
Logged

NoFoodAfterMidnight

  • Ensign
  • *
  • Posts: 39
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4852 on: August 23, 2019, 06:25:51 AM »

How are buffs to fighters handled? Right now I'm giving a combat buff to all ships within a fleet using .getFleetData().getMembersListCopy(), which is working for the ships but not the fighters. I've looked at the fighter-specific skills, which led me to the skill effect type but no reference as to how it's affecting fighters.

Also where are derelict ships created after combat (the ones floating through space), and where is ship recovery handled?
Logged

MrHoon

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4853 on: August 23, 2019, 08:33:20 AM »

Is it possible Im importing the wrong things?
It looks to me like you've got all your bases covered as far as imports are concerned. My guess at this point is that there's something wrong with your hull_mods.csv file. If you want to zip up your mod and send it to me I'd be happy to take a look.

@Varya: This stretches the limits of my knowledge a bit (hopefully Alex will correct me if I'm wrong), but...
Looking through decompiled code of createFleetMember, I see that it assigns the instance of the variant you pass it, so it looks to me like it should be the same key. Of course, it's always possible that it's changed later. If you want to make sure, you should be able to check for instance equality like this:
Code
if(if(member.getVariant() == shipData.variant)) {
    // Notify you somehow
}
clone() creates a new instance, which is the method of comparison used by HashMaps for objects that don't override equals() and hashCode(), so each clone should work as a unique key, even if they all have the same values.

sure thing, here is the file. I've tried everything and at this point its just a simple mistake i missed

[attachment deleted by admin]
Logged

Zer0

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4854 on: August 23, 2019, 08:38:56 AM »

Hello!

Recently I have been working on a mod that adds an Industry which effects kick in after a cycle. For that, I made two separate buildings:
  • MyIndustryBuilding - 60 days to build, after it's completion it automatically starts upgrading to (2):
  • MyIndustryBuilding_Complete -360 days to finish upgrading. If the player cancels the upgrade mid-way the construction progress doesn't drop to 0 but it starts decreasing until it reaches 0 and destroys itself. If it finishes upgrading its effects kick in, and when the player wants to shut it down, it goes to (1) from the maximum build progress and starts decreasing it until 0.

When I went to test it, I noticed the left-click (or right-click, I forgot) menu wasn't really what I wanted. For example, when it reaches (2) it says "downgrade to (1)..." but I wish for it to say something else. I had gone digging and haven't found anything regarding said menu or its options. Also, I wanted to have the option "cancel downgrade" added when going from (2) to (1) (or after the upgrade to (2) is cancelled) but I had similar luck and have found nothing that I could use.

My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17397
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4855 on: August 23, 2019, 09:54:52 AM »

... and I can therefore store data in the hullmod with the ShipVariantAPI as a key

There's only one instance of each HullModEffect *per application session*, and it doesn't go into the savefile, at any rate. I'd say as a general rule, just don't do it period. E.G. if the variant - or whatever data you store keyed off it - references the Sector somewhere down the line, bam, that's a Sector-sized memory leak when you load a game.

If you need to store stuff long-term, use Global.getSector().getMemory() or Global.getSector().getPersistentData(). It's about the same, really, as far as which to use; persistentData is just a straightforward map.


How does economyIntervalnGameDays affect patrols? I noticed that it may have something to do with battles lost.

It used to affect their spawn rate but doesn't anymore. See: averagePatrolSpawnInterval

(You might be looking at some older PatrolFleetManager* classes which are no longer used...)


How are buffs to fighters handled? Right now I'm giving a combat buff to all ships within a fleet using .getFleetData().getMembersListCopy(), which is working for the ships but not the fighters. I've looked at the fighter-specific skills, which led me to the skill effect type but no reference as to how it's affecting fighters.

Fighters don't exist in the campaign in the same way that ships do, so if you're going to buff them, it needs to happen in combat. Probably better to do this for ships, too - what you're doing might be alright, but it's just easier to do something with long-term effects if it's not managed properly. (See: BuffManagerAPI, TempBuff etc...)

For example, using .getFleetData().getMembersListCopy() would only work if you're using that to apply Buffs, not modify stats directly. If you're already doing that, though, and it expires (or doesn't) in the way that you want, you're probably fine.

Also where are derelict ships created after combat (the ones floating through space), and where is ship recovery handled?

See: CoreScript.generateOrAddToDebrisFieldFromBattle()

Also see: ShipRecoverySpecial and SalvageSpecialInteraction


Hello!

Hi!

My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.

Ahh, these really aren't configurable, the upgrading/downgrading works along a pretty set pattern. You might be able to do something with the 2nd building being "upgradeable" to the first, though - then it'd take time to "downgrade" (via an upgrade) so it'd probably be closer to what you want.

But "it takes time to shut down", I can't see how to make work, offhand. Just in general, that menu isn't very configurable, aside from being able to take custom special items.
Logged

Zer0

  • Ensign
  • *
  • Posts: 2
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4856 on: August 23, 2019, 10:36:37 AM »

My question is how would it be possible (if at all) to rename a context menu option (right/left click menu on a Building), or even perhaps remove, change behaviour or add a new option.

Ahh, these really aren't configurable, the upgrading/downgrading works along a pretty set pattern. You might be able to do something with the 2nd building being "upgradeable" to the first, though - then it'd take time to "downgrade" (via an upgrade) so it'd probably be closer to what you want.

But "it takes time to shut down", I can't see how to make work, offhand. Just in general, that menu isn't very configurable, aside from being able to take custom special items.

Dang, no luck with the menu.
Fortunately, I did manage to do what I wanted to do with the delayed shutdown/effects in a kinda hacky way, but if it works it works!

Anyway, thank you  ;D!
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1314
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4857 on: August 23, 2019, 10:53:11 AM »

Stupid question that I know was already answered, but I cannot find it in the thread.

For burst weapon, damage per shot = total damage of the burst?
So a 3 round burst weapon with 300 daamge_per_shot means 100 damage per shot in reality?
Logged

Salv

  • Lieutenant
  • **
  • Posts: 56
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4858 on: August 23, 2019, 10:53:55 AM »

It used to affect their spawn rate but doesn't anymore. See: averagePatrolSpawnInterval

(You might be looking at some older PatrolFleetManager* classes which are no longer used...)

I see, thank you. One more thing. I know that sound is muted when you can't see the source. I increased zoom distance a bit and when i pan the camera a bit off the center of my ship, due to long range weapons, there is no sound despite the source being in the frame (closer to the edges but still).

Really a minor thing, but i'm wondering if there is a way to adjust it. Did take a glance at the code but figured i might just ask, since i understand that not everything is moddable.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17397
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4859 on: August 23, 2019, 11:04:05 AM »

Stupid question that I know was already answered, but I cannot find it in the thread.

For burst weapon, damage per shot = total damage of the burst?
So a 3 round burst weapon with 300 daamge_per_shot means 100 damage per shot in reality?

Per shot is per shot, not per burst. (Edit: to be 100% clear, in your example, it'd be 900 damage per burst.)

(The only sort-of-exception here is multi-barreled beams where the damage per second is the total for all barrels.)


I see, thank you. One more thing. I know that sound is muted when you can't see the source. I increased zoom distance a bit and when i pan the camera a bit off the center of my ship, due to long range weapons, there is no sound despite the source being in the frame (closer to the edges but still).

Really a minor thing, but i'm wondering if there is a way to adjust it. Did take a glance at the code but figured i might just ask, since i understand that not everything is moddable.

Right, yeah, that's another thing that's not moddable - sound playback is based on the distance of the sound from the center of your view, and if it's too far (based on a hardcoded value), it just doesn't play at all.
Logged
Pages: 1 ... 322 323 [324] 325 326 ... 467