Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.98a is out! (03/27/25)

Pages: 1 ... 13 14 [15] 16 17 ... 45

Author Topic: API request thread (please read OP before posting!)  (Read 274101 times)

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #210 on: May 25, 2014, 02:18:09 PM »

MissionDefinitionAPI

api.addEveryFrameCombatPlugin(org.blah.missions.plugins, myMissionScript);

I'm confused. There's already:
MissionDefinitionAPI.addPlugin(EveryFrameCombatPlugin plugin);
Am I missing something here?


Documentation? Neither in the source code or the JavaDoc do you state that *that* is what that plugin does specifically. Thank you for clarifying that. I suggest that you might get less questions with more detailed API documentation. The JavaDoc is my proverbial bible when looking for how to do things. Though the comments you have at the moment are fairly good in most areas, in others no such documentation exists or it is spread out over multiple posts. The forum board/threads is a very inefficient method of having a KB article system, and the search results are often ... erroneous.

At the moment there are only a handful of people that really have an idea about undocumented features - such as that post on how to get the EveryFrameCombatPlugin loaded - there are something like 5 methods of which I only ever knew of one, and LazyWizard was the only other person on the entire planet that knew the other 4.



On a general note: this thread is turning a bit into "questions about how to do stuff", in part, because some of the stuff being asked for is already possible. This is going to make it much more time-consuming to go through later and figure out what actually needs to be added. If you're not sure whether something can already be done or not, please ask about it in the Modding section first.

It's also not about requesting new features (the Suggestions forum is there for that), but rather about exposing functionality - via the API - that's already in the game. There's some gray area there, of course, but still. If feature suggestions were to go in this thread, it'd be completely unmanageable, and it's going into that territory. A good rule of thumb is that if the core game doesn't already do what you're asking for or something very close to it, then it doesn't belong here.


CombatFleetManagerAPI.holdTheLine() prevents the enemy AI from calling a retreat. They fight to the death and the very last ship...including ships the are generated from spawnShipOrWing.

For example - absolutely not to single you out personally - this kind of thing definitely belongs in Suggestions and not here.


I'd like to keep this thread clean and focused. Thanks! :)


Well fair enough to single me out, I do post a large number of requests - and that one was admittedly not the best one I've had and was a reference to Mass Effect humor...but anyway I think another way to get a similar effect is to enumerate all FleetMembers and set them to suicidal - in theory.

Anyway I'll try to have less frivolous requests and hope that the handful of people who know the undocumented API functions are around when I need to ask them.

That said is boolean Global.isAlexAwesome() which always returns true such a bad suggestion?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 25935
    • View Profile
Re: API request
« Reply #211 on: May 25, 2014, 02:39:10 PM »

Spoiler
Documentation? Neither in the source code or the JavaDoc do you state that *that* is what that plugin does specifically. Thank you for clarifying that. I suggest that you might get less questions with more detailed API documentation. The JavaDoc is my proverbial bible when looking for how to do things. Though the comments you have at the moment are fairly good in most areas, in others no such documentation exists or it is spread out over multiple posts. The forum board/threads is a very inefficient method of having a KB article system, and the search results are often ... erroneous.

At the moment there are only a handful of people that really have an idea about undocumented features - such as that post on how to get the EveryFrameCombatPlugin loaded - there are something like 5 methods of which I only ever knew of one, and LazyWizard was the only other person on the entire planet that knew the other 4.
[close]

Fair enough re: documentation. The plugins are also the part where stuff gets a little too arcane. Just, you know, a method with that exact signature already exists, so I don't think it's unfair to consider it, ah, "due diligence" to look at whether it already does what you want :) There's also an example of it being used (BattleCreationPluginImpl, this line: loader.addPlugin(new EscapeRevealPlugin(context))).

Anyway, again, not trying to single you out or jump on you. This isn't a big deal, and stuff like that is bound to come up due to aforementioned deficiencies in documentation. I just want to keep this thread a little more on track, that's all. Not putting feature requests here is the much bigger point; a "can you add this/it's already there" exchange is easy enough to skim through.

That said is boolean Global.isAlexAwesome() which always returns true such a bad suggestion?

Terrible - too much pressure :)
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #212 on: May 25, 2014, 03:01:43 PM »

That's the thing, I actually looked at several missions and I found addPlugin(new EscapeRevealPlugin(context)) so I thought it had to do with some EscapeRevealPlugin which didn't seem relevant to what I was trying to achieve.

However if I'd just had a look at a few more missions, and I'd opened the Bismarck mission it probably would have twigged at about line 94:

Code: java
		api.addPlugin(new EveryFrameCombatPlugin() {
public void init(CombatEngineAPI engine) {
engine.getContext().setStandoffRange(10000f);
}
public void advance(float amount, List events) {
}
});


That makes sense to me.

I have a bit of a concern though with this method of adding a plugin. Normally when I do a plugin, I either clear out lists in the Init or in advance section from the previous engine.

However if the plugin is not run again in another instance of combat, those lists/hashmaps etc. might remain there in memory until the application closes. So if the use case is the user plays the mission with the script X that stores various ship data, they then complete the mission, then go off and play the campaign I'm not certain that the GC would cleanup my lists/hashmaps properly, potentially leading to a crash due to lack of memory on 32-bit systems.

Anyway aside from the GC of mission EveryFrameCombatPlugin scripts lists, I think it seems fairly straight forward after looking at the bismarck mission.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #213 on: May 27, 2014, 05:36:16 AM »

CombatEngineAPI.endCombat(float delay, Fleetside enum)

At the moment when I end combat using the endCombat method it will default to the player losing, but I may want them to win according to my specifications. So if I can say *who* won...we can have some fun arcade missions ^_^.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #214 on: May 30, 2014, 06:25:46 PM »

Global.getShipVariants() return List<ShipVariantAPI> of all variants across all vanilla and all loaded mods

I guess what I'm trying to do is to be able to randomly grab variants of ships to spawn them, or having to always rely on certain mods being loaded. I can request a list of all variants, interrogate various attributes and pick them accordingly to spawn them.

Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request
« Reply #215 on: May 30, 2014, 06:29:48 PM »

You can do this already.  See how the Random Battle code in Vacuum works.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #216 on: May 30, 2014, 10:30:38 PM »

It's a rather inventive way of achieving it, it's not portable though, you still rely on there being a .faction file available and that has to be inside your own mod directory, it doesn't traverse across all mods loaded?
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request
« Reply #217 on: May 30, 2014, 11:19:46 PM »

Well, I didn't write it for portability; you need to figure stuff like that out :)

That said... it's pretty straightforward, I think.
Code: java
File dir = new File("data/world/factions/");
File[] files = dir.listFiles(new FilenameFilter() {
    public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".faction");
    }
});

...gets you every single .faction file.  Read into JSON.  Do whatever analysis thing you want once you have the data set.  Should be straightforward to push it all to a string table, eliminate all matches, etc.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #218 on: June 04, 2014, 08:26:42 PM »

Well, I didn't write it for portability; you need to figure stuff like that out :)

That said... it's pretty straightforward, I think.
Code: java
File dir = new File("data/world/factions/");
File[] files = dir.listFiles(new FilenameFilter() {
    public boolean accept(File dir, String name) {
        return name.toLowerCase().endsWith(".faction");
    }
});

...gets you every single .faction file.  Read into JSON.  Do whatever analysis thing you want once you have the data set.  Should be straightforward to push it all to a string table, eliminate all matches, etc.

Without even trying I'm fairly sure that Starsector would block me from doing anything with the File object or anything in the java.util.io or java.util.file would be prevented from doing anything meaningful. Going to do a post about that.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request
« Reply #219 on: June 05, 2014, 12:24:47 AM »

Ah, yeah.  I keep forgetting about that, because I've really not had any serious problems with it thus far.

Anyhow, you can do it via loadJSON() using all of the known faction names; it's not like there are that many factions out there.  Exceptions could be handled without serious problems.  You're dealing with a very finite search space and a small amount of data entry, so, no biggie, just do some data entry.


Logged
Please check out my SS projects :)
Xeno's Mod Pack

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2887
    • View Profile
    • Sc2Mafia
Re: API request
« Reply #220 on: June 17, 2014, 03:19:03 AM »

SoundPlayerAPI.playMusic()

Please.  Many mods really need something like this.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request
« Reply #221 on: June 27, 2014, 09:21:17 PM »

ShipAPI boolean isGroupAutofire(int group)
ShipAPI void setGroupAutoFireOn(int group)

We can't get direct access to the states of Autofire for a Group atm via ShipAPI. 

Would be nice to just go in and change the booleans for that Group without having to use giveShipCommand(), since it has some issues with taking a bunch of toggle orders per frame and we can't query the state of the boolean's current value at all.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request
« Reply #222 on: June 30, 2014, 07:07:33 PM »

CombatEngineAPI endCombat(float) should take an additional parameter, a boolean for whether the Player has won or not. 

Using this currently always results that the player has lost the battle when the EngagementResultAPI is read later on in the post-battle process atm :)
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: API request
« Reply #223 on: July 30, 2014, 10:23:15 AM »

engine.spawnDamagingExplosion() - exactly like the spawnExplosion but does damage.

No longer require an AOE/Flak type damage API. This is quite doable with LazyLib, and failing that just a bit of fudge work.

Though I am curious as to what the damage level is outside the 'core' radius in a proximity fuse weapon?
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1374
    • View Profile
    • GitHub Profile
Re: API request thread (please read OP before posting!)
« Reply #224 on: July 30, 2014, 02:44:22 PM »

I updated the OP with a list of current requests and their status, as well as some guidelines for posting in this thread. These are the same guidelines that have been mentioned in this thread before; it's just slightly more useful for them to actually be written down somewhere. ;)

Let me know if I missed anything while collating the previous 15 pages. I should note I deliberately excluded a few suggestions that were closer to feature requests - those should have their own threads so they can be discussed without cluttering this thread - as well as requests that already had a negative reply from Alex (here or elsewhere on the forum).

I should also apologize for renaming a few suggested methods. I just couldn't help myself. :)
« Last Edit: July 30, 2014, 03:18:13 PM by LazyWizard »
Logged
Active mods: LazyLib | Combat Radar | Console Commands | Version Checker  ||  Old mods: Autosave | Omnifactory | Simulator Overhaul
Feel free to use any code I've written or PM me for help with your own. Anyone is free to translate my work.
Pages: 1 ... 13 14 [15] 16 17 ... 45