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: Simulator Enhancements (03/13/24)

Author Topic: great sucsess halp is no longer needed  (Read 2653 times)

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
great sucsess halp is no longer needed
« 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?)
« Last Edit: October 21, 2013, 08:24:24 AM by dmaiski »
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: how do i attach an EveryFrameCombat script to a missile???
« Reply #1 on: October 21, 2013, 08:23:41 AM »


halp is no longer needed
Logged
BISO
(WIP) lots of shiny new weapons ( :-[ i have more weapons then sprites :-[ )

i got a cat pad
its like a mouse pad but better!

etherealblade

  • Commander
  • ***
  • Posts: 134
    • View Profile
Re: great sucsess halp is no longer needed
« Reply #2 on: October 22, 2013, 04:06:28 AM »

Is it possible to have effects that cause ships to go hurling backwards from the force?
Logged
Spoiler

[close]

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: great sucsess halp is no longer needed
« Reply #3 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)
Logged

phyrex

  • Admiral
  • *****
  • Posts: 751
    • View Profile
Re: great sucsess halp is no longer needed
« Reply #4 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  ;)
Logged