Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Wurst Missile System

Discussion in 'The Lab' started by Lake, Feb 3, 2019.

  1. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Just curious if anyone has created a missile system for Wurst yet, which is open for public use? Otherwise I would attempt to make one, since it seems like a pretty useful tool for quite a few maps. :)
     
  2. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    So I decided to work on this myself, as I thought it might be good practice. The project will be public on GitHub here :)

    @mods should I keep the thread open for development updates or should I move it out somewhere it?
     
  3. Watsuby

    Watsuby

    Joined:
    Dec 16, 2011
    Messages:
    12
    Resources:
    0
    Resources:
    0
    Not sure how helpful this will be but I was looking through the Wurst showcase repos and Gold Rush has some missile code.

    WurstScript • Showcase

    HannesHaglund/Gold-Rush

    If I remember correctly the game had fire-in-a-line missiles to swap places with target unit or knockback in an aoe.
    It was pretty neat that they separated the concept of the collision detection (they called it Sensors) with the actual projectile.
     
  4. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Dude, it's super cool that you looked that through - didn't think of that mysef :D I'll try to take a look at the system, and see if there is anything I can use. It seems though, that his are line-missile (as you mention), but I want to develop a system which can handle all types of missiles.

    Like the idea of sensors, just not sure if it's a good idea for efficiency
     
  5. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    I am using this. Might be useful for you. Its an abstract base class for custom projectile. Currently it only offers warcraft 3 style projectiles aka. unit homing and ground-target, with arc (gravity) if desired.
    island-troll-tribes/island-troll-tribes
     
  6. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Dude, I believe that's exactly what I'm looking for! Probably want to reconsider now if I wanna make my at all ;)
     
  7. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
  8. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Cool! Right, I see that you can't adjust the arc manually, but instead you have to adjust the gravity?
     
  9. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    Yeah. I didnt know how the arc formula worked with original projectile so the gravity causes the same effect. The higher the gravity the higher the arc the projectile has to make to reach target before hitting ground, basically. And 0 means no arc.
     
  10. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Right, that's good to know ;)

    With my own system, I'm trying to implement an adjustable arc measured in radians. It should be possible, and not that hard. I think I have the idea down, I just can't get the calculations to be correct :D
     
  11. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    In a sense that would not be realistic for the flight path though. If you you mean the launch angle would be the same regardless of distance.
    But if you anyways need say, the projectile to reach a certain height, you will need to adjust the gravity based on the distance and horizontal speed. There is a simple formula in wikipedia for maximum height reached by a projectile Projectile motion - Wikipedia
     
  12. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    That's what I mean, and theoretically it whould be possible, as you would instead adjust the vertical velocity of the missile. My tests have found, that that seems to be how the original wc3 missiles are calculated.

    You shouldn't have to tweak the gravity as far as I know. And as I mentioned above, the height of the missile is not determined by the horizontal distance, but rather by the vertical velocity, the gravity and the angle at which the projectile is fired. ;)
    Been messing around with a few of the formulas on that wiki page as well :D
     
  13. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    Oh, right. If you want to keep the angle same you got to adjust the force at which the missile is fired instead. I just dont see how that would make sense with the homing component, which mystically gives the missile force to reach its target even if it moves away. Basically how my class works, is it calculates the required vertical speed on every update so if the target position changes it adapts the flight path like wc3 projectiles do.
    Code (Text):
           
    //Update vertical speed for appropriate flight arc
    let flightTime = distance2D / this.groundSpeed
    real heightDifference = (this.targetPos - missileFx.getPos3()).z
    this.verticalSpeed = (heightDifference / flightTime) - (0.5 * this.gravity * flightTime)
     
  14. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    However the calculations for required launch angle to reach a certain point is quite complex and only necessary if you want completely physics driven projectiles. And with a long enough distanc the projectile cannot even reach the target, so you cant just give it a point and tell it to fire there, since the force might not be high enough.

    When you think how my system would work if it was a cannon firing, it would increase the angle & firing force so that the horizontal distance stays the same while still reaching the target point.
     
  15. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Right, you might be on to something with that homing component - not my focus at the moment :D But I suppose that should be able to be calculated the same way. Whether you adjust the "arc" of the missile in flight or the vertical velocity should be the same.

    ... On a side note: I actually tested the original wc3 missiles, and they don't home as smoothly as your solution at all ;) Rather, they just abrutly stop their smooth curve and instead just aim directly for the target in a linear path - it looks quite ridiculous.
     
  16. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    What is the application you are going for here exactly? I can hopefully help you as long as I understand what is the end goal of how you need your projectiles to work.
     
  17. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    Well, I don't need anything that works better than your solution, tbh ;) Now it's more of a challenge for myself to create such a system. But the primary hurdle atm is to figure out how to calculate the correct initial vertical velocity, when giving the parameters: distance, angle, and horizontal speed
     
  18. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    I believe
    Vertical launch speed = tan(angle) * horizontal launch speed

    However, if distance and horizontal speed and angle are a given, the flight path is basically set for a given gravity, therefore you must adjust the gravity to reach the target.
     
  19. Lake

    Lake

    Joined:
    Mar 5, 2015
    Messages:
    135
    Resources:
    0
    Resources:
    0
    The gravity or the vertical velocity ;)

    Haven't stumpled on that formular though - that would make my life so much easier.
     
  20. GuineapigRoast

    GuineapigRoast

    Joined:
    Jan 31, 2019
    Messages:
    27
    Resources:
    0
    Resources:
    0
    Thats simply not correct. The vertical velocity is only adjustable through firing angle, which you said was a given parameter. If you instead increase the initial total velocity ("cannon propulsion force") it will also increase the horizontal velocity unless you also change the angle.
     
    Last edited: Feb 7, 2019