Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: .getProjectileSpeed()  (Read 3794 times)

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
.getProjectileSpeed()
« on: November 04, 2013, 04:21:51 PM »

nm im a noob...
Spoiler
set to give projectile speed in arbitary units
game uses completely different units in combat for length measurements.... (in combat)
getProjectileSpeed() is uterly usless... (for anything to do with coding)
 :'( :'( :'(

how many times its multiplied... (~350)
Spoiler
[close]
[close]
« Last Edit: November 05, 2013, 12:43:02 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!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: .getProjectileSpeed()
« Reply #1 on: November 04, 2013, 04:31:55 PM »

Please keep posts in the bug reports section to actual bugs.

If there's a specific issue, it helps to provide relevant details instead of saying something doesn't work/is useless/etc. That's literally not helpful at all; I have *no* idea what you're trying to do with it, what you think the problem is - you've got to get into the details.

For reference, getProjectileSpeed() returns the speed in pixels/second, at the default zoom level (the one where ship sprites are at the same size they actually are, pixel for pixel.) As far as I understand, it works, as a number of things are using it and seem to function properly. That doesn't mean there isn't a problem somewhere, but, again, this is where the details are useful and general statements not so much.
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: .getProjectileSpeed()
« Reply #2 on: November 04, 2013, 04:35:43 PM »

its not that it dose not work, it's that it isn't very useful for most things i can think of that would require exact determination of how fast a weapons projectile can move (like evil "ninjas everywhere" ai scripts)

meh i'll just use a multiplier to get the equivalent lengthsquared value that can actually be used for combat scripts

posted picture compared getVelocity().lengthsquared/getProjectileSpeed
« Last Edit: November 04, 2013, 04:39:29 PM 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!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24125
    • View Profile
Re: .getProjectileSpeed()
« Reply #3 on: November 04, 2013, 04:57:58 PM »

That... didn't really clear anything up. Try to consider how what you're saying looks to someone that only has the information you've put down to go on, and doesn't know what you're thinking :)
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: .getProjectileSpeed()
« Reply #4 on: November 04, 2013, 05:36:35 PM »

what is expected of .getProjectileSpeed(): returns the speed a projectile is fired at in terms of projectile.getVelocity().lengthSquared()

so projectile.getVelocity().lengthSquared() == projectile.getWeapon().getProjectileSpeed()


what actualy occurs:
.getProjectileSpeed() is 350 times slower then .getVelocity().lengthSquared()

so projectile.getVelocity().lengthSquared() != projectile.getWeapon().getProjectileSpeed()


why: because in combat evrything moves in terms of .getVelocity().lengthSquared() not pixles/s, so any mesurment that is in pixles/s is not useful for modding puropses.



sample code...
Spoiler
Code: java
public class hammer implements OnHitEffectPlugin {


    public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target,
                      Vector2f point, boolean shieldHit, CombatEngineAPI engine)
    {
        float emp = projectile.getEmpAmount();
        float dam = projectile.getDamageAmount();
        float vel = projectile.getVelocity().lengthSquared();
        float initvel = projectile.getWeapon().getProjectileSpeed();
        float damagemullt = (vel/(initvel*350))-1; //how much more damage it dose based on speed compared to original speed
        //350mult needed to get normal projectile speed value
        float damend = dam*damagemullt; //damage
        float empend = emp*damagemullt; // emp
        engine.applyDamage(
                target, point,
                damend, projectile.getDamageType(),
                empend,
                false,
                true,  //deals soft flux?
                projectile.getSource());


        //engine.addFloatingText(projectile.getLocation(), "damage " + ((double)damagemullt) + " mult!", 20f, Color.BLUE, projectile.getSource(), 1f, 0f);
        //testing
    }
}
[close]
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!

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7224
  • Harpoon Affectionado
    • View Profile
Re: .getProjectileSpeed()
« Reply #5 on: November 04, 2013, 05:50:51 PM »

Quick question... does the projectile in question have a speed of 350? Because getVelocity.lengthSquared() is just that - the magnitude of the velocity squared. If the projectile speed is 350, then 350*350 is 350 squared. If its not speed 350, then something is wrong - but either way the two functions should definitely not return the same things.
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: .getProjectileSpeed()
« Reply #6 on: November 04, 2013, 06:38:27 PM »

Thaago lets go back to basic Euclidean geometry  ;D

Spoiler
line segments A, B, C form a right angle triangle
projectile.getVelocity()=Vector2f //the projectiles velocity vector in a given direction
Vector2f= (X,Y)
A is X axis
B is Y axis
vector without direction is a number (mostly refered to as speed for a velocity vector)
C is speed(for starsector purposes)
A^2+B^2=C^2 (Pythagorean theorem)
so...
sqrt(A^2+B^2)=C
or (drum roll plz)
Vector2f.lengthsquared=C=speed

[close]

then again i am a fan of the masters of non-Euclidean geometry
Spoiler
[close]
« Last Edit: November 04, 2013, 06:43:58 PM 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!

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7224
  • Harpoon Affectionado
    • View Profile
Re: .getProjectileSpeed()
« Reply #7 on: November 04, 2013, 08:11:02 PM »

Sorry man, you are wrong. Length squared gives the length squared: http://lwjgl.org/javadoc/org/lwjgl/util/vector/Vector2f.html#lengthSquared%28%29
No square root.

Seriously though: is the projectile speed 350? If yes, then its working. If no, its a bug and should be reported.

Aside: the reason that length squared is used instead of length, which is more intuitive, is because it is computationally costly to take the square root - and for many purposes that you want length not needed.
« Last Edit: November 04, 2013, 08:13:24 PM by Thaago »
Logged

dmaiski

  • Captain
  • ****
  • Posts: 422
  • resistance is futile
    • View Profile
Re: .getProjectileSpeed()
« Reply #8 on: November 05, 2013, 12:42:02 AM »

you learn something new everyday i guess

Aside: the reason that length squared is used instead of length, which is more intuitive, is because it is computationally costly to take the square root - and for many purposes that you want length not 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!