Fractal Softworks Forum

Starsector => Mods => Modding => Topic started by: dmaiski on October 19, 2013, 03:51:34 PM

Title: great sucsess halp is no longer needed
Post by: dmaiski on October 19, 2013, 03:51:34 PM
now, as many of you may have seen i have created quite an abomidable piece of code due to my unsatisfaction with curent MIRV behaviour...

now what do i do with it?

this is how far i have gotten (help me im stupid and dont actualy know how to get it to work!!!)
Spoiler
Code: java
package data.scripts.EveryFrameCombatPlugin;


import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.EveryFrameCombatPlugin;
import com.fs.starfarer.api.combat.MissileAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import org.lwjgl.util.vector.Vector2f;

import java.util.List;

import static org.lazywizard.lazylib.combat.CombatUtils.getShipsWithinRange;

public class Scatterb implements EveryFrameCombatPlugin {

    private IntervalUtil tracker = new IntervalUtil(0.35f, 0.4f);
    private static CombatEngineAPI activeEngine;

    public void advance(float amount, MissileAPI missile, CombatEntityAPI target, CombatEngineAPI engine, java.lang.String SBKR1, List events) {

        if (getShipsWithinRange(missile.getLocation(), 400f, true).get(0).isAlive())
        {
            target = getShipsWithinRange(missile.getLocation(), 400f, true).get(0);
            {
                //create variables
                //capitalized can be changed

                //insert targeter code here (anything goes, you may need to change it so T gives tx/ty a float value
                //see at bottom for possible code
                CombatEntityAPI T = target;//end point of " " (enemy api/point in space/ect) for targeter
                MissileAPI P = missile;    //start point of " " for weapon
                float px = P.getLocation().getX();   //get location og p (for center of dakakakaka)
                float py = P.getLocation().getY();
                //float mvx = missile.getVelocity().getX();
                //float mvy = missile.getVelocity().getY();
                float tx = T.getLocation().getX();   //get location of t (for center of pew pew)
                float ty = T.getLocation().getY();
                double rxd = .5 - Math.random(); //generate a random double with -vs component, range -.5 to +.5
                float rx = (float)rxd*2;          // convert to float
                double ryd = .5 - Math.random();
                float ry = (float)ryd*2;
                double rpd = Math.random(); //+ve random
                float rp = (float)rpd;
                float Tvar = 50f; //radius of t (sets mirv spread (angular))
                float Pvar = 1f;   //variable for vectors can use random float
                double prany = py/Math.abs(py)*Pvar;
                double pranx = px/Math.abs(px)*Pvar;
                float prx = (float)pranx;
                float pry = (float)prany;
                float Rvar = 5f; //how much the velocities of projectiles can vary
                double rvd = .5 - Math.random(); //generate random velocity multiplier for smooth function (to arr roughness back in
                float rv = (float)rvd*Rvar;



                //math

                float Fx = (tx * rx * Tvar);  //create randomized point field to shoot at
                float Fy = (ty * ry * Tvar);
                float Vx = (Fx * px * prx);         //create vectors for pewpews to follow
                float Vy = (Fy * py * pry);
                double Smoothv = (Math.sqrt(((tx-px)*(tx-px))+((ty-py)*(ty-py)))/Math.sqrt((Vx*Vx)+(Vy*Vy)))*rv;   //smoothes out ragged shot
                float Sv = (float) Smoothv;
                Vector2f Pjv = new Vector2f(Vx*Sv, Vy*Sv);   //make the actual vector

                engine.spawnProjectile(null, null,
                        SBKR1,
                        missile.getLocation(), 0,Pjv);

                engine.removeEntity(missile); //make missile go poof
            }

    }
    }



    @Override
    public void advance(float amount, List events) {




    }

    @Override
    public void init(CombatEngineAPI engine) {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
[close]

i am trying to attach it to missiles so it will run as an every frame script and check for a ship in range (and when ship is in range trigger my special MIRV behaviour)

i would love even the most basic example of how to implement this(so i can run it ingame), i can probably work out how to customize it to do what i want after that. (i already have the script up, but how to stick it onto a missile?)
Title: Re: how do i attach an EveryFrameCombat script to a missile???
Post by: dmaiski on October 21, 2013, 08:23:41 AM
(http://fc07.deviantart.net/fs71/i/2012/116/4/f/great_success_by_merionminor-d4xmjry.png)
halp is no longer needed
Title: Re: great sucsess halp is no longer needed
Post by: etherealblade on October 22, 2013, 04:06:28 AM
Is it possible to have effects that cause ships to go hurling backwards from the force?
Title: Re: great sucsess halp is no longer needed
Post by: phyrex on October 22, 2013, 10:52:10 AM
Is it possible to have effects that cause ships to go hurling backwards from the force?

Absolutely, someone has already done it in fact. forgot who however :/
Whomever it was, he made a ship system that creates a shockwave that sends ships and missile hurling backward (distance depending on ship mass)
Title: Re: great sucsess halp is no longer needed
Post by: phyrex on October 22, 2013, 12:06:17 PM
I know the Thule Legacy guy has done it.  His largest ship creates a shockwave that pushes everything on the battlefield a substantial amount.

the "thule legacy guy" is called...Thule. really hard i know  ;)