Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: penetrate armor  (Read 6447 times)

xangle13

  • Lieutenant
  • **
  • Posts: 68
    • View Profile
Logged

HELMUT

  • Admiral
  • *****
  • Posts: 1363
    • View Profile
Re: penetrate armor
« Reply #1 on: March 15, 2013, 06:34:40 AM »

That's how the gauss-canon should be. Very cool stuff. Also i wonder, is it possible to make a weapon who can shoot through the enemy shield?
Logged

sc90

  • Ensign
  • *
  • Posts: 26
    • View Profile
Re: penetrate armor
« Reply #2 on: March 15, 2013, 07:05:12 AM »

That's how the gauss-canon should be. Very cool stuff. Also i wonder, is it possible to make a weapon who can shoot through the enemy shield?

Would be cool if there was weapon capable of partial shield penetration :O like you shoot at enemy and only 40% dmg would get through if enemys shield is up
Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: penetrate armor
« Reply #3 on: March 15, 2013, 07:13:03 AM »

@xangle13
second epic onhit weapon effect.
you really shoud post your hulls and scripting as mod, it will be popular.
Logged

JT

  • Commander
  • ***
  • Posts: 129
    • View Profile
Re: penetrate armor
« Reply #4 on: March 15, 2013, 09:38:32 AM »

Wow, that is amazing. That's a cool enough effect that it should be part of the standard game, in my opinion.


For those people wary of the link, it is a video which showcases a custom-scripted shield-ricochet, where projectiles that impact the shields will bounce off.  It also showcases overpenetration of projectiles, where once those projectiles hit the ship, causing damage, they will continue to pass through it.
Logged

Andy H.K.

  • Commander
  • ***
  • Posts: 232
    • View Profile
Re: penetrate armor
« Reply #5 on: March 15, 2013, 10:24:45 AM »

Question: Does it actually damage armor along the way?
Logged

JT

  • Commander
  • ***
  • Posts: 129
    • View Profile
Re: penetrate armor
« Reply #6 on: March 15, 2013, 06:39:02 PM »

Good question. I can't say for sure, but based on the video it looks as though it simply punches one entry wound and one exit wound, and I'm not entirely certain the exit wound has any actual damaging effect either.
Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: penetrate armor
« Reply #7 on: March 15, 2013, 06:51:53 PM »

it does damage, and armor penetration effect lookslike creation of other projectile with same params as first one from other side of hull, since no code attached it can be not true.
Logged

xangle13

  • Lieutenant
  • **
  • Posts: 68
    • View Profile
Re: penetrate armor
« Reply #8 on: March 15, 2013, 09:02:36 PM »

penetrate armor

http://www.tudou.com/v/jEip1MVC0yY/&rpid=4866143&resourceId=4866143_04_05_99/v.swf



package data.scripts.effect;

import java.awt.Color;

import org.lwjgl.util.vector.Vector2f;

import com.fs.starfarer.api.combat.CombatEngineAPI;
import com.fs.starfarer.api.combat.CombatEntityAPI;
import com.fs.starfarer.api.combat.DamageType;
import com.fs.starfarer.api.combat.DamagingProjectileAPI;
import com.fs.starfarer.api.combat.OnHitEffectPlugin;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
import com.fs.starfarer.api.combat.FluxTrackerAPI;
import com.fs.starfarer.api.combat.ArmorGridAPI;

public class OnHit_AP_Effect implements OnHitEffectPlugin {
   public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
      if (target instanceof ShipAPI) {
         ShipAPI sourceShip = projectile.getSource();
         if(sourceShip != null){
            WeaponAPI weaponFrom = projectile.getWeapon();
            if(weaponFrom != null){
               Vector2f projectileLocation = projectile.getLocation();
               Vector2f projectileVelocity = projectile.getVelocity();
               
               Vector2f targetLocation = target.getLocation();
               Vector2f targetVelocity = target.getVelocity();
               
               float pointRange = (float)Math.sqrt((point.getX() - targetLocation.getX()) * (point.getX() - targetLocation.getX()) + (point.getY() - targetLocation.getY()) * (point.getY() - targetLocation.getY()));
               double cosValue = (double)((point.getX() - targetLocation.getX())/pointRange);
               float hitAngle = (float)(Math.acos(cosValue) * (180/Math.PI));
               if(point.getY() < targetLocation.getY()){
                  hitAngle = 360 - hitAngle;
               }
               
               pointRange = (float)Math.sqrt(projectileVelocity.getX() * projectileVelocity.getX() + projectileVelocity.getY() * projectileVelocity.getY());
               cosValue = (double)(projectileVelocity.getX()/pointRange);
               float fromAngle = (float)(Math.acos(cosValue) * (180/Math.PI));
               if(projectileVelocity.getY() < 0){
                  fromAngle = 360 - fromAngle;
               }
               
               float reflectAngle = (hitAngle + hitAngle - fromAngle) % 360f + 180;
               
               float damageAmount = projectile.getDamageAmount();
               float empAmount = projectile.getEmpAmount();
               DamageType damageType = projectile.getDamageType();
               
               if(shieldHit){
                  float reboundAngle = (hitAngle > fromAngle)?(hitAngle - fromAngle):(fromAngle - hitAngle);
                  reboundAngle = reboundAngle > 180f?(360f - reboundAngle):reboundAngle;
                  //engine.addFloatingText(point, "" + reboundAngle, 20, new Color(255,255,255,255), target, 1f, 2f);
                  if(reboundAngle <= 150){
                     engine.spawnProjectile(null, null, weaponFrom.getId(), point, reflectAngle, null);
                     
                     engine.addFloatingText(point, "???", 30, new Color(225,200,50,255), target, 1f, 2f);
                     //FluxTrackerAPI targetFlux = ((ShipAPI)target).getFluxTracker();
                     //if(targetFlux != null){
                        //float hardFlux = targetFlux.getHardFlux();
                        //targetFlux.decreaseFlux(damageAmount * 2f);
                     //}
                  }else{
                     engine.applyDamage(target, point, damageAmount * (float)(Math.random() * 0.25 + 0.25), damageType, empAmount, false, false, null);
                  }
               }else{
                  ArmorGridAPI targetArmorGrid = ((ShipAPI)target).getArmorGrid();
                  float targetArmorRating = targetArmorGrid.getArmorRating();
                  float penetrateValue = damageAmount * 3.5f - targetArmorRating;
                  
                  if((penetrateValue > 0) && (targetArmorRating > 0) && ((float)Math.random() <= (penetrateValue / targetArmorRating))){
                     Vector2f penetrateVelocity = new Vector2f(projectileVelocity.getX(),projectileVelocity.getY());
                     penetrateVelocity = penetrateVelocity.normalise(penetrateVelocity);
                     Vector2f penetrateLocation = new Vector2f(point.getX()+penetrateVelocity.getX()*50f , point.getY()+penetrateVelocity.getY()*50f);
                     
                     engine.spawnExplosion(penetrateLocation, new Vector2f(penetrateVelocity.getX()*50f, penetrateVelocity.getY()*50f), new Color(225,200,50,200), damageAmount / 10f, 0.5f);
                     for(int i = 0;i < (int)(damageAmount / 50);i++){
                        engine.addHitParticle(penetrateLocation, new Vector2f(penetrateVelocity.getX()*200f+(float)(Math.random()*100-50), penetrateVelocity.getY()*200f+(float)(Math.random()*100-50)), (float)(damageAmount / 50), 0.5f, 3f, new Color(225,200,50,200));//Color(225,200,50,200)
                     }
                     
                     CombatEntityAPI projectileSpawned = engine.spawnProjectile(null, null, weaponFrom.getId(), penetrateLocation, fromAngle, null);
                     ((DamagingProjectileAPI)projectileSpawned).setSource((ShipAPI)target);
                     
                     engine.applyDamage(target, point, damageAmount * (float)(Math.random() * 1 + 1), damageType, empAmount, true, true, null);
                     
                     engine.addFloatingText(penetrateLocation, "???", 30, new Color(255,0,0,255), target, 1f, 2f);
                  }
               }
            }
         }
      }
   }
}
Logged

xangle13

  • Lieutenant
  • **
  • Posts: 68
    • View Profile
Re: penetrate armor
« Reply #9 on: March 15, 2013, 09:05:43 PM »

@xangle13
second epic onhit weapon effect.
you really shoud post your hulls and scripting as mod, it will be popular.

It's a mod,but not in english language.
Logged

RawCode

  • Admiral
  • *****
  • Posts: 511
    • View Profile
Re: penetrate armor
« Reply #10 on: March 15, 2013, 10:16:37 PM »

english language is not hurge issue, amount of texts allow to translate everything every without skills in korean chinese in day or two.


ps. i was right with implementation
Quote
effect lookslike creation of other projectile with same params
« Last Edit: March 16, 2013, 01:20:52 AM by RawCode »
Logged

TJJ

  • Admiral
  • *****
  • Posts: 1905
    • View Profile
Re: penetrate armor
« Reply #11 on: March 16, 2013, 05:13:17 AM »

Such a minor issue.....but won't switching the source of the exiting projectile mean that it'll hit the wrong team's fighters?
Logged

Flare

  • Admiral
  • *****
  • Posts: 906
    • View Profile
Re: penetrate armor
« Reply #12 on: March 16, 2013, 05:14:21 AM »

I checked out the, really liking what I see. Although a more apt name would probably be deflecting off the ship rather than penetrating it.
Logged
Quote from: Thana
Quote from: Alex

The battle station is not completely operational, shall we say.

"Now witness the firepower of this thoroughly buggy and unoperational batt... Oh, hell, you know what? Just ignore the battle station, okay?"

Sproginator

  • Admiral
  • *****
  • Posts: 3592
  • Forum Ancient
    • View Profile
Re: penetrate armor
« Reply #13 on: April 13, 2013, 05:36:58 PM »

How do i implement this? :/
Logged
A person who's never made a mistake, never tried anything new
- Albert Einstein

As long as we don't quit, we haven't failed
- Jamie Fristrom (Programmer for Spiderman2 & Lead Developer for Energy Hook)

Pelly

  • Admiral
  • *****
  • Posts: 757
    • View Profile
Re: penetrate armor
« Reply #14 on: April 13, 2013, 05:52:14 PM »

How do i implement this? :/
um lazys done this and polished it and will be releasing it soon i think (from Starfarer skype chat)
Logged