Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.9.1a is out! (05/10/19); Blog post: Raiding for Fun and Profit (11/27/19)

Pages: 1 2 3 [4]

Author Topic: [0.9.1] MagicLib v0.28 (2019/11/09)  (Read 77645 times)

Mongreal

  • Ensign
  • *
  • Posts: 33
    • View Profile
    • Email
Re: [0.9.1] MagicLib v0.28 (2019/11/09)
« Reply #45 on: Today at 04:28:47 AM »

Quote
MagicGuidedProjectileScript (allows projectiles to track their target)
What could prevent this script from working ?

Does this (well, it's not the complete script I'm using but it's the part used with projectile that use the MagicGuidedProjectileScript) should work ? :
Spoiler
Code
List<DamagingProjectileAPI> projectiles = engine.getProjectiles();
            int size = projectiles.size();
            for (int i = 0; i < size; i++) {
                proj = projectiles.get(i);
                String spec = proj.getProjectileSpecId();
                WeaponAPI mainWeapon = proj.getWeapon();

                if (mainWeapon.getShip().getShipTarget() != null) {
                    target = mainWeapon.getShip().getShipTarget();
                } else {
                    target = AIUtils.getNearestEnemy(proj);
                }

                switch (spec) {
                       case LIGHT_PLASMA_DART_PROJECTILE_ID:
                              isGuided = true;
                       break;

             if (isGuided) {
                  engine.addPlugin(MagicGuidedProjectileScript(proj, target));
             }
[close]
Logged
Pages: 1 2 3 [4]