Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 534 535 [536] 537 538 ... 710

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8025 on: October 04, 2021, 10:42:03 AM »

Does anyone know what the float that FactionAPI.pickShipAndAddToFLeet() returns is? Is it maybe the amount of FP the method added to the fleet?

From the javadoc:
Returns a total weight of ships added to the fleet. Generally will return
1 when ships were added, 0 when they weren't, and a number >1 when adding, say,
a medium ship instead of a small one because no small ones are available.




I would like the player to be able to explore the derelict only when they have dealt with the patrolling fleet. Right now I have put a tag on the derelict that is removed once the player talk to the fleet and select an option (going throught rule.cmd). I would like to make sure the derelict is explorable if the fleet is destroyed, either by the player or another fleet. (or even if its engaged with something else). How would I go doing that?

The simplest thing would be to do something like this:
triggerMakeFleetIgnoredByOtherFleets();
triggerMakeFleetIgnoreOtherFleetsExceptPlayer();
triggerFleetAddDefeatTrigger("YourRuleTrigger");

Which would fire YourRuleTrigger when the fleet is defeated, and rule out the case of "destroyed by something else". (See: FleetInteractionDialogPlugin, around line 2002, for some variables you can check when that trigger is fired.)

You could also, instead of a tag, set a memory value on the entity using
triggerSetEntityFlag(flag, Object ... stages)
That will automatically be removed when the mission ends; not necessarily applicable here but might be handy.

And, finally, if you want to catch all cases of the fleet fighting something, you could call:

triggerCustomAction()

And then provide a custom action that addes a FleetEventListener to the TriggerActionContext.fleet when it's called. You could make your mission class implement FleetEventListener just for convenience, and have the doAction() method call "context.fleet.addListener(YourMission.this)". Hope that makes sense!

Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8026 on: October 05, 2021, 06:14:28 AM »

Any thoughts on how one would find out from what mod a given skin of a vanilla ship originates from? It's not connected to any .csv, so getMergedSpreadsheetDataForMod() and "fs_rowSource" isn't an option, nor can you glean information from looking at the base hull, given it's a vanilla ship. I'm wondering if there's anything obvious or convenient that I'm missing.

dcong89

  • Ensign
  • *
  • Posts: 40
  • Work Hard Play Hard
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8027 on: October 05, 2021, 07:04:48 AM »

hi guys

this error keep make the game crash (it's said Fatal:4) when i refit and add hull mods to some ships.

184747 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.ArrayIndexOutOfBoundsException: 4
java.lang.ArrayIndexOutOfBoundsException: 4
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus$ShipStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.campaign.fleet.FleetMemberStatus.applyHullFractionDamage(Unknown Source)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.applyDamageToFl eetMember(BattleAutoresolverPluginImpl.java:490)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.computeOutcomeF orFleetMember(BattleAutoresolverPluginImpl.java:690)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolveEngageme nt(BattleAutoresolverPluginImpl.java:333)
   at com.fs.starfarer.api.impl.campaign.BattleAutoresolverPluginImpl.resolve(BattleAutoresolverPluginImpl.java:243)
   at com.fs.starfarer.campaign.fleet.Battle.doAutoresolveRound(Unknown Source)
   at com.fs.starfarer.campaign.fleet.Battle.advance(Unknown Source)
   at com.fs.starfarer.campaign.BaseLocation.advanceEvenIfPaused(Unknown Source)
   at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source)
   at com.fs.starfarer.campaign.CampaignState.advance(Unknown Source)
   at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
   at com.fs.state.AppDriver.begin(Unknown Source)
   at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
   at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)
Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8028 on: October 05, 2021, 04:38:44 PM »

Any thoughts on how one would find out from what mod a given skin of a vanilla ship originates from? It's not connected to any .csv, so getMergedSpreadsheetDataForMod() and "fs_rowSource" isn't an option, nor can you glean information from looking at the base hull, given it's a vanilla ship. I'm wondering if there's anything obvious or convenient that I'm missing.
A "good enough" method would be trying to load the skin's json data using Global.getSettings().loadJSON("/data/hulls/skins/skin_id.skin", modID) for each mod.

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8029 on: October 06, 2021, 01:56:40 AM »

Is there any way to influence restore ship logic? I'd like to add some extra conditions, say require Metals based on the hull size, or specific industry being present on the market used to restore...
« Last Edit: October 06, 2021, 12:49:59 PM by Jaghaimo »
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 #8030 on: October 06, 2021, 07:52:38 PM »

Can I directly use Vertex Array/Buffer Object in OpenGL while modding?
Logged
My mods


Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8031 on: October 07, 2021, 11:37:24 AM »

Is there any way to influence restore ship logic? I'd like to add some extra conditions, say require Metals based on the hull size, or specific industry being present on the market used to restore...

There isn't, no - that'd require UI changes, too (showing requirements etc) and none of it is set up for that. Could of course be done with an entirely custom dialog option, though, just not through the refit screen.

Can I directly use Vertex Array/Buffer Object in OpenGL while modding?

I don't see why not!
Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8032 on: October 09, 2021, 03:02:22 PM »

Is there any way to figure out what weapon or projectile flak AoE damage comes from? It appears to be an instance of DamagingProjectileAPI, but returns null for getWeapon() and getProjectileSpecId(). Asking because I'm trying to do an onhit effect for a flak gun- but flak AoE doesn't trigger onhit scripts, apparently. So I did it with a listener instead, and ran into the previously mentioned problem.

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 #8033 on: October 09, 2021, 10:58:59 PM »

Can I directly use Vertex Array/Buffer Object in OpenGL while modding?

I don't see why not!
Welll...I am just considering about if there are someone whose gpu is not compatible with OpenGL 3.0...
Logged
My mods


Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8034 on: October 10, 2021, 12:17:39 AM »

Can CampaignPlugin.pickAutofitPlugin be marked as @Deprecated? It took me a while to figure out why mine wasn't being called.

(CoreAutofitPlugin is called from the fleet inflater, which is the plugin I actually need to have a picker for)

EDIT: or alternatively, make the inflater actually use the plugin pick
« Last Edit: October 10, 2021, 12:22:08 AM by Histidine »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8035 on: October 11, 2021, 10:25:28 AM »

Asking because I'm trying to do an onhit effect for a flak gun- but flak AoE doesn't trigger onhit scripts, apparently.

Hmm, really? It's supposed to apply any on hit effects from the weapon - so the "onHitEffect" would be specified in its normal place, not inside the explosionSpec, for example.

Welll...I am just considering about if there are someone whose gpu is not compatible with OpenGL 3.0...

Ah - I mean, that's up to you to decide if you care about that, not really a question I can answer.

Can CampaignPlugin.pickAutofitPlugin be marked as @Deprecated? It took me a while to figure out why mine wasn't being called.

(CoreAutofitPlugin is called from the fleet inflater, which is the plugin I actually need to have a picker for)

EDIT: or alternatively, make the inflater actually use the plugin pick

Ahh! That method *is* used by the refit screen. What DefaultFleetInflater does is kind of... up to what it wants to do, if that makes sense - it *happens* to use CoreAutofitPluginImpl because it's convenient and that implementation does double-duty as far as being used both for player refit and for NPC fleets, but that's not a required state of affairs.

Added a comment to pickAutofitPlugin() to clarify that it's only used for the refit screen.
Logged

shoi

  • Admiral
  • *****
  • Posts: 658
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8036 on: October 12, 2021, 06:29:19 PM »

If I wanted to apply a certain damage modifier to a damage API, would this be the right way to go about it ? The main thing im unsure about is how to apply mults and percentmod together.
Code
DamageAPI damage;

float damageMod = ( damage.getStats().getDamageToFighters().getPercentMod()/100f ) * damage.getStats().getDamageToFighters().getMult())

damage.setMultiplier( damage.getMultiplier() + damageMod );


Logged

theDragn

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8037 on: October 13, 2021, 01:43:48 AM »

Hmm, really? It's supposed to apply any on hit effects from the weapon - so the "onHitEffect" would be specified in its normal place, not inside the explosionSpec, for example.

I've double-checked this; the onhit gets called if I remove the proximity explosion, but does not get called when I add it back in. Presumably it has something to do with the projectile exploding without touching anything- the damage applied by the flak AoE returns null if you try to get its projectile ID or source weapon.
.wpn file, in case I'm smoking something (the script is just some extra damage and graphical effects, nothing terribly fancy):
Spoiler
{
   "id":"apex_flak_shot",
   "specClass":"projectile",
   "spawnType":"BALLISTIC",
   "collisionClass":"PROJECTILE_FF",
   "collisionClassByFighter":"PROJECTILE_FIGHTER",
   "onHitEffect":"data.weapons.proj.ApexQGOnHit",
   "length":35.0,
   #"length":0,
   "hitGlowRadius":10,
   "width":6.5,
   "fadeTime":0.2,
   "fringeColor":[255,245,175,200],
   "coreColor":[255,250,225,200],   
   #"fringeColor":[255,50,50,0],
   #"coreColor":[255,255,200,0],   
   "textureScrollSpeed":64.0,
   "pixelsPerTexel":5.0,
   "bulletSprite":"graphics/missiles/shell_large_blue.png",
   #"bulletSprite":"",
   "behaviorSpec":{"behavior":"PROXIMITY_FUSE",
               "range":35,
               #"vsMissileRange":100,
               "explosionSpec":{"duration":0.1f,
                            "radius":50,
                            "coreRadius":35, # full damage within core radius - also equal to proximity fuse range
                            "collisionClass":PROJECTILE_FF,
                            "collisionClassByFighter":PROJECTILE_FIGHTER,
                            "particleSizeMin":3.0,
                            "particleSizeRange":3.0,
                            "particleDuration":1,
                            "particleCount":100,
                            "particleColor":[255,245,175,255],
                            "sound":"explosion_flak"},
               }
               
}
[close]

Also, do CombatEngineAPI's applyDamage(), spawnDamagingExplosion(), and spawnEmpArc() methods automatically do Targeting Analysis's bonus damage vs different ship sizes? Or do I need to add that in myself?

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8038 on: October 13, 2021, 04:25:40 AM »

I am about to try something new, and add new types of colonies to the game. By new, I mean new implementations of MarketAPI interface. Before I start (interface is large) I wanted to confirm there is no magic involved anywhere else in the (obfuscated) code, and that I can happily replace vanilla MarketAPI objects with my own.

I want to achieve the following (not limited to):
  • Custom colony where stability is always fixed
  • Custom colony which can build only specific ships
  • Custom colony which does not spawn ships / trades
  • Custom colony that does not have any demands
  • Custom colony that does generate income (only drains)
  • Custom colony that does not accept administrators (even the player, and thus does not affect admin cap)
« Last Edit: October 13, 2021, 04:28:36 AM by Jaghaimo »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8039 on: October 13, 2021, 01:24:59 PM »

If I wanted to apply a certain damage modifier to a damage API, would this be the right way to go about it ? The main thing im unsure about is how to apply mults and percentmod together.
Code
DamageAPI damage;

float damageMod = ( damage.getStats().getDamageToFighters().getPercentMod()/100f ) * damage.getStats().getDamageToFighters().getMult())

damage.setMultiplier( damage.getMultiplier() + damageMod );

You want to use damage.getModifier() - it returns a MutableStat which you can then modify with a percentage and a multiplier separately.

I've double-checked this; the onhit gets called if I remove the proximity explosion, but does not get called when I add it back in. Presumably it has something to do with the projectile exploding without touching anything- the damage applied by the flak AoE returns null if you try to get its projectile ID or source weapon.

Ah, my bad - the onHitEffect needs to be inside behaviorSpec (but *not* inside explosionSpec).

Also, do CombatEngineAPI's applyDamage(), spawnDamagingExplosion(), and spawnEmpArc() methods automatically do Targeting Analysis's bonus damage vs different ship sizes? Or do I need to add that in myself?

It should apply automatically.

I am about to try something new, and add new types of colonies to the game. By new, I mean new implementations of MarketAPI interface. Before I start (interface is large) I wanted to confirm there is no magic involved anywhere else in the (obfuscated) code, and that I can happily replace vanilla MarketAPI objects with my own.

Ah, that's definitely not going to work. Generally speaking when something is *API it's just an interface to expose core functionality, and when something is *Plugin, it's something that can actually be replaced by an alternative implementation.
Logged
Pages: 1 ... 534 535 [536] 537 538 ... 710