Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: Romeo_One on January 17, 2013, 03:21:12 PM

Title: The Code Foundry
Post by: Romeo_One on January 17, 2013, 03:21:12 PM
Hey guys,

I saw a few random threads popping up asking for scripts and plugins, so I was thinking that it might be better if we would gather all requests in one place. It makes organizing these things easier.

Also I would like to gather all scripts and plugins here that are available for the community.
So if you have scripts and plugins that you wish to share, just post them up, I will add them to the list.

Its also a nice way of giving our code-mongerers a bit of credit and exposure.

LazyWizards LazyLib, a library for modders
Link to original thread (http://fractalsoftworks.com/forum/index.php?topic=5444.0)

Chain Lightning Beam Effect : by LazyWizard  - Needs to be attached to a weapon
You need to add a "BeamEffect" to a beamweapon.
Link (http://www.mediafire.com/download.php?pz2c08gfbfcgbv2)

Ejecting Escape Pods : by silentstormpt - Needs to be attached to a weapon
You need to add an "everyFrameEffect" to it and link the script. You can configure the amount of pods and when its triggered.
Link (http://www.mediafire.com/download.php?tsaddsw1qbq5yzd)
Video (http://www.youtube.com/watch?v=29AejSDmVDM&feature=youtu.be)

Rotating Dish : by Okim - Needs to be attached to a weapon
This script allows objects to rotate 360 degrees, it has to be called by an "EveryFrameEffect".
Link (http://www.mediafire.com/download.php?7b129kia3s3wlhl)


Spawning electric arcs on damaged ships : by Psyion - Has to go into the "plugin" folder
Spawns electric arcs on damaged ships.
Link (http://www.mediafire.com/download.php?c4wlproc8n2o2o3)
Spoiler
(http://img4.imageshack.us/img4/9022/arcs.jpg)
[close]

Spawning explosions on a ship : by silenstrompt - Has to go into the "plugin" folder
Spawns explosion on damaged ships.
Link (http://www.mediafire.com/download.php?bhetjy0sc2pwm9b)
This library is required: Link (https://bitbucket.org/LazyWizard/lazylib/get/default.zip)

Broadside weapon covers - animated : by xangle13 - Needs to be attached to a weapon
Controls broadside weapon animations.
Link (http://www.mediafire.com/download.php?b0daa5z8cm4x4w0)
Video - hosted on a chinese(?) website. (http://www.tudou.com/v/macsg-tpSnQ/&rpid=4866143&resourceId=4866143_04_05_99/v.swf)

Bridge Communication : by xangle13 - Has to go into the "plugin" folder
A script that adds bridge communication.
Link (http://www.mediafire.com/download.php?9cc4kn28m8nbyt6)
Video - hosted on a chinese(?) website. (http://www.tudou.com/v/macsg-tpSnQ/&rpid=4866143&resourceId=4866143_04_05_99/v.swf)

Play an animation when venting flux : by Okim - Needs to be attached to a weapon
An animation is played when venting, needs a "decorative" "weapon" using this effect.
Link (http://www.mediafire.com/download.php?trdj13z2yd5841p)
Video (http://www.okim.nickersonm.com/SF/AnimatedVenting.avi)


An alternate script for flux venting : by silentstormpt - Needs to be attached to a weapon
Link (http://www.mediafire.com/download.php?1c83yt90xc1cmmd)

Animation when ship system is used : by silentstormpt - Needs to be attached to a weapon
Allows for things like drone hangar doors to open when releasing drones.
Link (http://www.mediafire.com/download.php?pajxn59qwv035m4)
Title: Re: The Code Foundry
Post by: arcibalde on January 18, 2013, 02:47:26 PM
I like this but could you add at least 1 pic (for every "effect") showing how it looks?
Title: Re: The Code Foundry
Post by: Romeo_One on January 18, 2013, 02:51:00 PM
Hmm, yeah sure can do, will add them tomorrow (GMT +1)

Title: Re: The Code Foundry
Post by: Nekora on January 18, 2013, 11:05:14 PM
Hey, the Rotating dish does not work.

I get the following error.

Caused by: org.codehaus.commons.compiler.CompileException: Source file "data/scripts/weapons/RotatingDish.java" does not declare class "data.scripts.weapons.RotatingDish"
Title: Re: The Code Foundry
Post by: Romeo_One on January 19, 2013, 12:04:10 AM
Do you call the script at: data.scripts.plugins.RotatingDish? Because thats where its package points at.

According to your error log, you call it at data/scripts/weapons/.
Title: Re: The Code Foundry
Post by: silentstormpt on January 19, 2013, 05:44:40 AM
if you want the script on that folder on the package it should be data.scripts.weapons;
Title: Re: The Code Foundry
Post by: Okim on January 19, 2013, 06:21:44 AM
You forgot this 'animate on venting' script: http://fractalsoftworks.com/forum/index.php?topic=431.msg83717#msg83717

And the you posted is a bit outdated. New one contains a check if the ship is a husk.
Title: Re: The Code Foundry
Post by: silentstormpt on January 19, 2013, 07:47:45 AM
Could you release the rotatingdisc with the "aim-that-target" code on it, thanks in advance
Title: Re: The Code Foundry
Post by: Romeo_One on January 19, 2013, 07:54:07 AM
@silentstormpt: mind putting LazyWizards library up, since I don't have it in .jar format right now and if I recall correctly your script (spawning explosions) needs to implement it, right?
Title: Re: The Code Foundry
Post by: silentstormpt on January 19, 2013, 07:59:11 AM
https://bitbucket.org/LazyWizard/lazylib/get/default.zip
Title: Re: The Code Foundry
Post by: CrashToDesktop on January 19, 2013, 08:45:24 AM
So, how does someone put these in a mod?  I'm still new to java and such. -_-
Title: Re: The Code Foundry
Post by: Romeo_One on January 19, 2013, 08:47:28 AM
That depends, some are just plugins, that you put into your plugin folder, I will mark those. Others are effects that are called from the "EveryFrameEffect" part in an animated weapon.
Title: Re: The Code Foundry
Post by: Nekora on January 19, 2013, 11:52:47 AM
Do you call the script at: data.scripts.plugins.RotatingDish? Because thats where its package points at.

According to your error log, you call it at data/scripts/weapons/.

damnit, i missed the package data.scripts.weapons; Thanks Romeo_One
Title: Re: The Code Foundry
Post by: ShadowFox on April 29, 2013, 05:49:32 PM
Can someone help me? I added this:

Quote
Spawning explosions on a ship : by silenstrompt - Has to go into the "plugin" folder
Spawns explosion on damaged ships.
Link
This library is required: Link

to my mod, and it caused an error. I will add the error info shortly. My coding skills are not up to speed yet.
Title: Re: The Code Foundry
Post by: Pelly on April 30, 2013, 02:37:20 AM
Can someone help me? I added this:

Quote
Spawning explosions on a ship : by silenstrompt - Has to go into the "plugin" folder
Spawns explosion on damaged ships.
Link
This library is required: Link

to my mod, and it caused an error. I will add the error info shortly. My coding skills are not up to speed yet.

ditto
Title: Re: The Code Foundry
Post by: silentstormpt on April 30, 2013, 06:20:14 AM
Can someone help me? I added this:

Quote
Spawning explosions on a ship : by silenstrompt - Has to go into the "plugin" folder
Spawns explosion on damaged ships.
Link
This library is required: Link

to my mod, and it caused an error. I will add the error info shortly. My coding skills are not up to speed yet.

Paste it, also, lazylib is required
Title: Re: The Code Foundry
Post by: LazyWizard on April 30, 2013, 02:55:55 PM
The explosion plugin used geom methods from an old, WIP version of LazyLib to get a point inside the ship's bounds. The entire org.lazywizard.lazylib.geom package has since been removed, the code would need to be updated to use CollisionUtils instead, something like this:

data/scripts/plugins/ExplosionDamageShipEffect.java:
Code
//Based on: Electrical Damage Plugin, by Psiyon
package data.scripts.plugins;

import java.awt.Color;
import java.util.Iterator;
import java.util.List;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.util.IntervalUtil;

import org.lazywizard.lazylib.CollisionUtils;
import org.lazywizard.lazylib.MathUtils;

public class ExplosionDamageShipEffect implements EveryFrameCombatPlugin
{
    /**
     * Set this to true to have the plugin actually do stuff.
     */
    private static boolean TEST_MODE = true;
    //Generates an interval between 0.5 and 3 seconds.
    private IntervalUtil interval = new IntervalUtil(0.5f, 3f);
    private CombatEngineAPI engine;

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

    @Override
    public void advance(float amount, List events)
    {
        //Makes sure this code doesn't run if test mode is inactive, or if the game is paused.
        if (!TEST_MODE)
        {
            return;
        }
        if (engine.isPaused())
        {
            return;
        }

        //Advances the interval.
        interval.advance(amount);

        //When the interval has elapsed...
        if (interval.intervalElapsed())
        {

            //cycles through all the ships in play.
            List ships = engine.getShips();
            Iterator it = ships.iterator();

            //While there are still more ships to cycle through...
            while (it.hasNext())
            {
                //loads the current ship the iterator is on into the object "ship"
                ShipAPI ship = (ShipAPI) it.next();

                //If the ship is disabled or is a fighter, we don't want to bother with arcs, so we'll start the loop over
                if (ship.isHulk())
                {
                    continue;
                }
                if (ship.isFighter())
                {
                    continue;
                }

                //If the ship has less than an eigth of its HP
                //if (ship.getHitpoints() <= ship.getMaxHitpoints() / 2.5f) {
                //Gets the (x,y) for the center of the ship in the map, for example if the map
                //Has 20000x20000 and the ship is in the middle of the map, its center would be 10000 x and 10000 y.
                Vector2f ShipCoords = getRandomPointInBounds(ship);

                // Colors for the effects
                Color explosioncolor = new Color(155, 100, 25, 255);
                Color explosionsmoke = new Color(255, 255, 255, 255);

                //spawns the explosion and other effects
                engine.addHitParticle(ShipCoords, ship.getVelocity(), 1f, 1f, 2f, explosionsmoke);
                // addSmoothParticle(Vector2f loc, Vector2f vel, float size, float brightness, float duration, Color color);
                engine.addSmokeParticle(ShipCoords, ship.getVelocity(), 1f, 255f, 5f, explosionsmoke);
                // addSmokeParticle(Vector2f loc, Vector2f vel, float size, float opacity, float duration, Color color);
                engine.spawnExplosion(ShipCoords, ship.getVelocity(), explosioncolor, 2f, 3f);
                // spawnExplosion(Vector2f loc, Vector2f vel, Color color, float size, float maxDuration);
            }

        }
    }

    private static Vector2f getRandomPointInBounds(ShipAPI ship)
    {
        int tries = 0;
        Vector2f point = new Vector2f();

        // Pick random points in the collision circle until one is inside the ship's bounds
        do
        {
            point.set(MathUtils.getRandomPointInCircle(ship.getLocation(),
                    ship.getCollisionRadius()));
            if (CollisionUtils.isPointWithinBounds(point, ship))
            {
                return point;
            }

            tries++;
        }
        while (tries < 30); // HIGHLY unlikely it will take more than two or three tries

        // Too many tries, give up and just return the center
        return ship.getLocation();
    }
}