Modding Help How do I make a gun apply knockback to myself?

Discussion in 'Starbound Modding' started by Low IQ Space Raptor, Sep 26, 2023.

  1. Low IQ Space Raptor

    Low IQ Space Raptor Space Spelunker

    Hello all, I've just joined the Starbound forums so forgive me if this post is structured improperly, this is my first time here.
    I've come asking for some advice or assistance, I have made a pistol with a charge mechanic and I desire to make the gun push the player away when firing the fully charged projectile. So far I thought about using the code from a grappling hook with some slight modification to get the desired effect, but I am unsure what to nab from it's code nor how to apply it to the gun. I am not that experienced in coding, this'd be my first time making something so advanced hence my confusion and requirement for assistance.
    I hope that those with a better understanding of modding can provide some assistance, either on what I need from the grappling hook or some other alternative to achieve what I desire.

    Edit as of 9/29/23: Also how do I make stance changes effect the full charge? I know this hasn't anything to do with the title but I didn't desire to make another post for something pertaining to the same weapon.
    In essence I can get the gun to have a two handed stance whilst using the normal fire, however I am unable to make it apply to the fully charged shot and all attempts either have no effect or crashes the game outright.
    I had to use the code from the already present charge weapons such as the dragonhead pistol and charge gun, if that information helps.

    Edit as of 9/30/23: As I failed to express in the previous edit, I had tried to make the gun a two handed weapon for balance reasons and due to this, I was attempting to make a custom version of the marked shot ability to use on the gun. In essence I wanted to make something unique so I chose to make a variation of said ability that had the same stats as firing the gun normally, the only benefit would be multi-target auto aim (something I had wanted to implement as my playstyle for starbound is mostly movement based), I've cracked open custom weapon ability mods, structured and coded everything to a T and it still does not work. I have the weapon ability buildscript patch, the ability itself, all structured in the same manner as the other ability mods and abilities for starbound itself. The ability either doesn't register as existing or it outright disables gun functionality for some unknown reason. If I have to do something to the gun directly or need some other file, it would be greatly appreciated if I were set in the right direction.

    Thank you for taking the time to read this post.
     
    Last edited: Sep 30, 2023
  2. Lemon drops

    Lemon drops Scruffy Nerf-Herder

    For the push back thing you could make it shoot an invisible projectile that dies instantly but creates the initial projectile you wanted it to shoot, and a second very fast backwards facing invisible projectile that does no damage but hits players and has knockback.
     
  3. Low IQ Space Raptor

    Low IQ Space Raptor Space Spelunker

    Apologies for the late reply, but, how would I go about making a different projectile with separate parameters fire from this gun? Funnily enough, prior to checking this post today I had came to the conclusion of using a secondary projectile for the knockback effect and I elected for an explosion for the additional visual flare since charge guns don't like it when you use muzzle flashes on them, the issue is I do not know how to structure the coding for such a thing.
     
  4. Lemon drops

    Lemon drops Scruffy Nerf-Herder

    this basically

    Code:
      "timeToLive" : 0.0,
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "insert bullet name",
          "inheritDamageFactor" : 1.0,
          "angleAdjust" : 0
        },
        {
          "action" : "projectile",
          "type" : "insert knockback projectile name",
          "inheritDamageFactor" : 0.0,
          "angleAdjust" : -180
        }
      ],
     

Share This Page