Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: OnHitEffectPlugin.onHit doesn't trigger when hitting a missile (with a missile)?  (Read 3245 times)

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile

I'm using an OnHitEffectPlugin on a missile, some code for the onHit method as follows:
Code
Global.getLogger(this.getClass()).info("hit");

if (target instanceof MissileAPI) {
            Global.getLogger(this.getClass()).info("hit missile");
}

So, the onHit method runs fine when a ship is hit by my missile, but when another missile is hit by my missile the OnHitEffectPlugin.onHit method isn't even run (tested hitting Pilum missiles), as in it doesn't even print "hit" to the log, let alone "hit missile". Is there a way to get the onHit code to run when another missile is hit?

Also, when my missile hits a Pilum missile it destroys it (perhaps this is why the onHit method isn't run?) even though I have set the damage of the missile to 0. Is there a way to get around this behaviour as well?

My assumption was that the OnHitEffectPlugin.onHit would run prior to the damage calculation, is this the case?

(questions questions questions :) )
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile

I think the issue here is that the other missile is counted as "hitting" the one that's got the on-hit effect, and not vice versa. In missile-missile collisions, the missile with more max hitpoints is the one that gets hit, and doesn't "hit" itself. That way you can have multiple PD missiles impact a single heavy missile, for example, without it being destroyed in one shot.
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile

I think the issue here is that the other missile is counted as "hitting" the one that's got the on-hit effect, and not vice versa. In missile-missile collisions, the missile with more max hitpoints is the one that gets hit, and doesn't "hit" itself. That way you can have multiple PD missiles impact a single heavy missile, for example, without it being destroyed in one shot.

Yeah I assumed this as well, but my missile definitely has less hit points (like 1/5) than the Pilum missile it is hitting (it has less mass as well, no damage, no EMP damage). It just destroys it in one hit and the OnHitEffect isn't run.  Hmm...

So, if my missile is 'smaller' (less hit points) it should be triggering it's OnHitEffect. Your example is along the lines of what I am going for, so I'll keep having a play with it and see if I can get it sorted :)
« Last Edit: January 19, 2016, 03:25:18 PM by Zaphide »
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile

I think the issue here is that the other missile is counted as "hitting" the one that's got the on-hit effect, and not vice versa. In missile-missile collisions, the missile with more max hitpoints is the one that gets hit, and doesn't "hit" itself. That way you can have multiple PD missiles impact a single heavy missile, for example, without it being destroyed in one shot.

OK, so after more testing this appears to be the opposite of what actually happens :P

I set my missile hitpoints at 10000 and it started running the OnHitEffect for my missile hitting a Pilum missile (hitpoints for Pilum is 50).

Also, my missile (now with 10000 hitpoints) gets destroyed in the missile-on-missile collision, rather than the Pilum .

So I think this may be a (minor modding) bug? :)
Logged

Dark.Revenant

  • Admiral
  • *****
  • Posts: 2806
    • View Profile
    • Sc2Mafia

The old greater-than / lesser-than bug.  Gets the best of us.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile

Oh dear. It was even worse than that; the code did the comparison, shuffled some stuff around, and then... switched it around again, for a different reason. Should be fixed!
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile

Oh dear. It was even worse than that; the code did the comparison, shuffled some stuff around, and then... switched it around again, for a different reason. Should be fixed!

Thanks Alex :)
Logged