Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Anubis-class Cruiser (12/20/24)

Pages: 1 ... 89 90 [91] 92 93 ... 748

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

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1350 on: February 07, 2014, 05:48:29 PM »

Does anyone know of a way to give a weapon the ability to temporarily disable enemy shields (Like a malfunction)? I'm looking to make a weapon that has a small chance to apply some catastrophic effect like one of the three major malfunctions (Engine, shield, weapon) to a target ship. I know how to increase the chance of those things happening to a ship, simply mutable stats, however I'm not sure how I would go about that with an on hit script. I'm not asking anyone to make me anything, but if anyone has any ideas I'd be very appreciative of a nudge in one direction or another.
Logged

Xalendi

  • Commander
  • ***
  • Posts: 198
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1351 on: February 07, 2014, 07:18:40 PM »

Is it possible to make a weapon's arc 'off-center'? As in, have the weapon facing forwards, but the center of the arc facing off to the side?
Logged

InfinitySquared

  • Commander
  • ***
  • Posts: 119
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1352 on: February 08, 2014, 11:14:24 AM »

What do I do again to make the missile drift or wait for a few seconds before engaging its engines?
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1775
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1353 on: February 08, 2014, 01:02:20 PM »

@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

@Xalendi: So you want a weapon to look like it's facing forward but shoot to the side? I think you could make that happen simply by rotating the sprite sideways, but you'd need two different weapons for left/right.

@Arumac: I don't know of a clean way to do that, but I think it could be hacked together. It might be easier for me to just write an example than to explain what I'm thinking in English though. Let me know if you want me to give it a shot.

InfinitySquared

  • Commander
  • ***
  • Posts: 119
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1354 on: February 08, 2014, 07:19:59 PM »

@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

That's just it. I remember there being such a setting, but the specifics of it are lost to me. It was used some of the older mods, as I recall.
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1355 on: February 08, 2014, 07:33:01 PM »

Can someone please explain to me the IntervalUtil class and how it relates to the combat engine and frames? Some examples would be greatly appreciated.
Logged

Arumac

  • Lieutenant
  • **
  • Posts: 98
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1356 on: February 08, 2014, 08:41:01 PM »

@InfinitySquared: If there's a setting for this I don't know about it, and I don't remember ever seeing a missile with an engine delay. I think you'd need to write a MissileAIPlugin to accomplish that.

That's just it. I remember there being such a setting, but the specifics of it are lost to me. It was used some of the older mods, as I recall.

I think you might be able to achieve that effect by making a MIRV missile that fires a single projectile, like a SABOT missile. You'd probably have to tweak the MIRV settings, but that might work.

@Sundog : Your help is always welcome and appreciated.
Logged

LazyWizard

  • Global Moderator
  • Admiral
  • *****
  • Posts: 1368
    • View Profile
    • GitHub Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1357 on: February 08, 2014, 09:18:12 PM »

Does anyone know of a way to give a weapon the ability to temporarily disable enemy shields (Like a malfunction)? I'm looking to make a weapon that has a small chance to apply some catastrophic effect like one of the three major malfunctions (Engine, shield, weapon) to a target ship. I know how to increase the chance of those things happening to a ship, simply mutable stats, however I'm not sure how I would go about that with an on hit script. I'm not asking anyone to make me anything, but if anyone has any ideas I'd be very appreciative of a nudge in one direction or another.

The Star Wars mod had a combat plugin that could disable shields temporarily. That might be a good base for what you're trying to do.

If I remember correctly, it did have a problem resetting shield upkeep cost when it re-enabled shields. It actually worked by removing the shield from your ship for the duration then adding a new, identical one once the timer was up, but the API at the time couldn't retrieve shield upkeep so that wasn't stored.


Can someone please explain to me the IntervalUtil class and how it relates to the combat engine and frames? Some examples would be greatly appreciated.

It's pretty simple once you get a handle on it. It's actually not based on the combat engine or frames or even time. This is because it doesn't advance on its own, you call its advance() method manually with the amount to advance by. While this is usually the time since the last frame, it doesn't have to be. You could just as easily use an IntervalUtil to keep track of how many times you fired a weapon for creating a special effect that only happens every <x> shots. :)

So, a basic example. Let's go with a common use, having an event happen occasionally during battle. Say you defined a new IntervalUtil with
Code: java
IntervalUtil example = new IntervalUtil(30f, 50f);
And in an EveryFrameCombatPlugin's advance(), you call example's advance() method with the time since last frame.

In this case, a random target number would be chosen between 30 and 50. When the total amount passed into this IntervalUtil's advance() method reaches that target, a few things happen:
  • intervalElapsed() will return true until you call advance() again (so make sure you check intervalElapsed() every time you call advance())
  • The target number will be reset to a new random number in the range you provided
  • The interval starts counting from 0 again

Here's a full example that shows a message every 30-50 seconds:
Code: java
package data.scripts.plugins;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.util.IntervalUtil;
import java.awt.Color;
import java.util.List;

public class IntervalUtilExample implements EveryFrameCombatPlugin
{
    // Used to have an event occur every 30-50 seconds
    // The 'target' interval will be randomly chosen between these two
    // numbers every time the IntervalUtil starts a new interval
    private final IntervalUtil exampleInterval = new IntervalUtil(30f, 50f);
    private CombatEngineAPI engine;
    
    @Override
    public void advance(float amount, List events)
    {
        // Advances the IntervalUtil by much time has passed since last frame
        exampleInterval.advance(amount);
        
        // Checks if the IntervalUtil has hit its target - will only be true for a single frame
        // Check this EVERY time you call advance(), otherwise you can miss elapsed events
        if (exampleInterval.intervalElapsed())
        {
            // Show a message every 30-50 seconds
            engine.addFloatingText(engine.getViewport().getCenter(),
                    "Interval elapsed!", 50f, Color.CYAN,
                    null, 0f, 0f);
            
            // After the interval has elapsed, IntervalUtil will automatically reset
            // and choose a new random target in the range you provided
            // You can change the IntevalUtil's target range using the following:
            //exampleInterval.setInterval(20f, 60f);
        }
    }

    @Override
    public void init(CombatEngineAPI engine)
    {
        this.engine = engine;
    }
}

There are a few other methods you can mess with once you've got the basics down, but that's all you really need to know. The full source for IntervalUtil is included in starfarer.api.zip in starsector-core. It's in com/fs/starfarer/api/util/IntervalUtil.java. :)
« Last Edit: February 08, 2014, 09:27:25 PM by LazyWizard »
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1358 on: February 08, 2014, 09:55:20 PM »

Thanks LazyWizard! That makes much more sense now.

The Starsector API has become such an impressive behemoth now now it's almost overwhelming trying to digest it all.
Logged

Xalendi

  • Commander
  • ***
  • Posts: 198
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1359 on: February 08, 2014, 11:54:49 PM »

Cheers, Sundog
Logged

Tecrys

  • Admiral
  • *****
  • Posts: 609
  • repair that space elevator!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1360 on: February 10, 2014, 02:47:42 AM »

Hi everyone!

I'm working on some new weapons and I thought and acid spray would be very cool.
Now what I think that weapon would need a script thet makes it deal damage over time.
I really have no idea how to do that.
I'm pretty sure I can make it look like a spray by using multible projectiles shot in a burst with some spread but how would I make it deal damage for a set amount of time, a few seconds, after the initial hit and only if it hit the hull of the target?
Logged
Symbiotic Void Creatures 0.5.0-alpha for 0.97a is out
https://fractalsoftworks.com/forum/index.php?topic=28010.0

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1361 on: February 10, 2014, 04:50:29 AM »

@Tecrys

I'll have a quick crack at it before I go to bed, I've been having no joy with my other coding project. One small victory would be nice for today.
Logged

Xalendi

  • Commander
  • ***
  • Posts: 198
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1362 on: February 10, 2014, 07:00:16 PM »

How do I change the pivot point of my turrets? Currently, it's about where the barrels meet the body of the turret, which puts them off-center when they turn.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1363 on: February 10, 2014, 07:05:57 PM »

The pivot point is determined by the center of the sprite XY.  To change that, you need to move the turret base and barrels upwards / downwards / sideways and also change your barrel points.

You can have turrets that are offset from the center, in the sense that, visually, they appear to be offset, but the center of the sprite is always used as the pivot point.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24947
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1364 on: February 10, 2014, 07:08:44 PM »

About weapon center: for turrets, yeah, it's the center of the sprite. For hardpoint weapons, iirc it's the center of the bottom half of the sprite.
Logged
Pages: 1 ... 89 90 [91] 92 93 ... 748