Modding Help Projectile Angle Changing.

Discussion in 'Starbound Modding' started by Dilrax, Feb 25, 2014.

  1. Dilrax

    Dilrax Ketchup Robot

    i know there are the two variables: "angle", and "angleadjust"
    "angle" being relative to the over all direction and overrides its current path, eg "angle" : 90, will cause the projectile to travel straight up regardless of what direction its fired at. and "angleadjust" changes the projectiles direction to change relative to the projectiles axis, eg "angleadjust" : 90, will add a 90 degree change in direction on top of the direction its already moving, for example if fired straight up (and your facing left) the projectile will travel to the right, if you shoot it to the left, the projectile will go up, ect...

    all this is relative to my problem, but i would rather use "angleadjust" so you have more control over the projectile, eg it goes in the direction you shoot it still.

    anyhow the current problem is im having a hard time figuring out a suitable JSON line of code that is able to repeat through each projectile, how ever it is possible, but im unable to figure out how to randomise the direction between two set amounts. this would be
    a direction between a 50 Degree angle down to 0 and then onto -50 degree angle.

    i have tried to make an attempt of using a format similar to that of a randomly generated weapon which is able to have random and different stats, for example: "rateOfFire" : [0.5, 4], how ever this sort of method doesn't seem to apply to custom items, the over all result of this which i aim to make is meant to be something like a Drunken Missile, which constantly/repeatedly changes its direction making its path unpredictable, a path that would be made between 4 identical missile files, allowing it to change direction in a random direction (but in the relative path its travelling) 4 different times.
    Code:
    {
    
    {
      "projectileName" : "RPDM1",
      "frames" : "RPDM.png",
      "animationCycle" : 0.25,
      "level" : 3,
      "frameNumber" : 1,
      "timeToLive" : 0.20,
      "pointLight" : false,
      "piercing" : false,
      "damageKindImage" : "RPDMicon.png",
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "RPDM2",
         "angleAdjust" : { "50, -50," },
         "inheritDamageFactor" : 1.0
        }
      ],
      "power" : 150.0,
      "damageType" : "hitTest",
      "damageKind" : "default"
    }
    first missile, it changes the overall direction upon
    becoming the second missile, eg, from right to up.
    Code:
    {
      "projectileName" : "RPDM2",
      "frames" : "RPDM.png",
      "animationCycle" : 0.25,
      "level" : 3,
      "frameNumber" : 1,
      "timeToLive" : 0.20,
      "pointLight" : false,
      "piercing" : false,
      "damageKindImage" : "RPDMicon.png",
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "RPDM3",
          "angleAdjust" : { "50, -50," },
          "inheritDamageFactor" : 1.0
        }
      ],
      "power" : 150.0,
      "damageType" : "hitTest",
      "damageKind" : "default"
    }
    second missile, though identical to the first one, randomly changes the overall direction again upon becoming the third missile as long as it doesn't hit anything, eg, right, up, left, third missile mimics the first two upon changing to the 4th missile, the 4th missile explodes upon impact if not in mid air when its "life" ends.


    anyone got an idea's or solutions on how to make this possible, with out error? or is it even possible do to in the first place...
     
    Last edited: Feb 25, 2014
    severedskullz likes this.
  2. Dilrax

    Dilrax Ketchup Robot

    still no one with any idea's, solutions or possibility's?
     
  3. Taren

    Taren Orbital Explorer

    Disclaimer: I don't know much about javascript and pretty much nothing about JSON. I have looked at a handful files and played a bit around, but that is pretty much it.

    Anyway, I am pretty sure that this isn't valid JSON. Here is how I understand JSON in general:

    • It is grouped as
      Code:
      "Variable name" : value
    • Possible value types are: 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', 'OBJECT', 'ARRAY'
    • Objects are grouped together by '{' and '}'
    • Arrays are grouped together by '[' and ']'
    So I am pretty sure that rateOfFire is an array. You are creating "Angle_adjust" as an object with the variable "50, -50,", but won't give that variable a value. Which kinda breaks the code. So you could let the projectile curve around rather easily but you probably need some LUA stuff to get a random movement pattern...
     
  4. Dilrax

    Dilrax Ketchup Robot

    i know nothing when it comes to java script, and i know very little still when it comes to JSON, but i know enough to get things working, i am aware the format for it is.
    Code:
    "angleadjust" : #value
      "angle" : #Value
    JSON format like the above would be preferable if you were able to give it an area value so that it randomly selects one number value from the provided area, eg possessive to negative(up/down radius from 0, = dead centre left/right), but by the looks of things you maybe right about needing to look into the LUA coding... which i know nothing about and have yet to understand anything in it, this i was afraid of having to do.
     
  5. Taren

    Taren Orbital Explorer

    Oh, something I completly forgot: What happens if you do this?

    Code:
     {
          "action" : "projectile",
          "type" : "RPDM2",
          "fuzzAngle" : 20,
          "adjustAngle" : 10,
          "inheritDamageFactor" : 1.0
        }
     
    Last edited: Mar 1, 2014
  6. Dilrax

    Dilrax Ketchup Robot

    i don't actually know, im not even sure if "fuzzangle" is something it recognises... worth the try though...
     
  7. Kawa

    Kawa Tiy's Beard

    It's a word that's actually in the program, so... probably? Looking around where I found it, I do see an "angleAdjust" where Taren has "adjustAngle", which is not in the program, soooo...
    liquid
    liquidId
    projectile
    type
    config
    inheritDamageFactor
    direction
    angle
    fuzzAngle
    angleAdjust
    autoFlipAdjust
    autoFlipAngle
    delaySteps
    spark
    particle
    specification
    explosion
    foregroundRadius
    backgroundRadius
    explosiveDamageAmount
    explosive
    tileDamageType
    placematerial
    background
    foreground
    spawnmonster
    arguments
    level
    offset
     
  8. Dilrax

    Dilrax Ketchup Robot

    this defiantly would be more helpful, may i ask where the list may possibly be found?
     
  9. Kawa

    Kawa Tiy's Beard

    starbound.exe, today's unstable release, offset 0x91F180, with fuzzAngle specifically at 0x91F1CB. Your mileage may vary depending on the exact build.
    * definitely
     
  10. Nightmanexe

    Nightmanexe Void-Bound Voyager

    I'm actualy having some problems with my coding too. I'm trying to change de angle of my fired projectile but when i put the "angleAdjust" It doesn't do anything! :(

    This is my what I have:

    {
    "projectileName" : "Meteorprojectile",
    "frames" : "Meteorprojectile.png",
    "animationCycle" : 0.15,
    "angleAdjust" : -70,
    "level" : 10,
    "frameNumber" : 1,
    "physics" : "bullet",
    "damageKindImage" : "Meteorprojectile.png",
    "pointLight" : false,
    "actionOnReap" : [
    {
    "action" : "config",
    "file" : "/projectiles/explosions/Impacteffect1/Impacteffect1.config"
    }
    ],
    "power" : 5.0,
    "damageKind" : "default"
    }


    Can someone help me?
     
  11. Dilrax

    Dilrax Ketchup Robot

    *facepalms* defiantly/definitely... i keep doing that. >.<

    and... you kinda lost me there, but not everything is perfect...
     
  12. Dilrax

    Dilrax Ketchup Robot

    you cant have the angle code where it is, it seems to ignore its existence in the line, generally having a projectile create a projectile to move things around to where they should be, which works good enough for me...
    for example... something that would work with your angle would be an added modifier to the projectile spawn, or how ever else one might say it... but in any case these example with the angle would work but only from the point on where the projectile is spawned.
    Code:
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "Meteorprojectile",
          "inheritDamageFactor" : 5.0,
          "angleAdjust" : -70
        }
    if its spawned up above in the sky, not a problem, if its spawned at say where your grenade exploded, its not gonna work... but im guessing the general idea is to possibly have a meteor rain down from above that travels on an angle?
     
  13. Nightmanexe

    Nightmanexe Void-Bound Voyager

    yeah I want to make some kind of meteor attack :D
    The thing is that the actiononreap code only works when the projectile hits something. I want to spawn a meteor from above that falls in a certain angle.

    Sorry for my bad programing skills :p
     
  14. Silmaril.SE

    Silmaril.SE Astral Cartographer

    So I've mucked about a bit, and made a projectile, that spawns another projectile on reap, that flies off in a randomised angle within 90 degrees either way of the original projectile direction. Would that be of any help?
     
  15. Nightmanexe

    Nightmanexe Void-Bound Voyager

    Hmm sounds very nice, could you share the code?
     
  16. Taren

    Taren Orbital Explorer

    You could also put something like this in a gun:

    Code:
    "projectile" : {
               
                "actionOnReap" : [
                    {
                        "action" : "projectile",
                        "fuzzAngle" : 20,
                        "inheritDamageFactor" : 1,
                        "projectileType" : "rocket"
                       
    
                    }
                ],
                "speed" :10,
                "timeToLive" : 0.9,
                "level": 30.0,
                "power": 30.0
            },
            "projectileType": "rocket",
    Interestingly enough you can modify the rocket projectile in the gun JSON files but not the ones for "action":"projectile"... At least I didn't find a way while scimming over the general guns. I just was interested if some kind of recursive JSON arguments would be possible since they would make it easy to bring many guns into multiplayer without any mods!

    Anyway, back to the .projectile file. I'm generally too lazy to copy-paste several files together to get multiple direction changes. Also, the rocket explodes every time when it changes direction... So I thought about using some kind of recursive hitTest type projectile until you actually hit something and switch to the actual explosion. Is something like this even possible without LUA?

    Anyway, here is a possible .projectile file:

    Code:
    {
      "projectileName" : "randomrocket2",
      "frames" : "rocket.png",
      "animationCycle" : 0.25,
      "level" : 1,
      "frameNumber" : 4, 
      "speed" :30,
      "damageKindImage" : "icon.png",
      "pointLight" : false,
      "power" : 5.0,
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "randomrocket2",
          "inheritDamageFactor" : 1,
          "adjustAngle" : 10,
          "fuzzAngle" : 20
        }
       
      ],
      "damageKind" : "default",
      "emitters" : [ "sparks" ]
    }
    
    Btw, is there a way to keep track of the projectiles with LUA? I guess you could tag them and then search using the World stuff, but that sounds terrible.
     
  17. Silmaril.SE

    Silmaril.SE Astral Cartographer

    Ive attached "Testmod". Its only attached to the human starter sword, so you'll have to start a new human character to see it.


    Important bits of code:

    humanstarter.sword:
    Code:
    "primaryStances": {
        "projectileType": "starcleaverswordslash",
        "projectile": {
          "speed": 0.1,
          "power": 3.0
        },
    starcleaverswordslash.projectile:

    Code:
      "actionOnReap" : [
    
        {
          "action" : "projectile",
          "type" : "starcleaverboom",
          "fuzzAngle" : 0,
          "inheritDamageFactor" : 1,
          "angleAdjust" : 0
        }
    
      ]
    starcleaverboom.projectile:

    Code:
    "actionOnReap" : [
    
        {
          "action" : "projectile",
          "type" : "starcleaverboom2",
          "fuzzAngle" : 90,
          "inheritDamageFactor" : 1,
          "angleAdjust" : 0
        }
    ]
    starcleaverboom2.projectile:
    Code:
    "actionOnReap" : [
    
        {
          "action" : "projectile",
          "type" : "starcleaverboom2",
          "fuzzAngle" : 0,
          "inheritDamageFactor" : 1,
          "angleAdjust" : 0
        }
    ]
     

    Attached Files:

  18. Nightmanexe

    Nightmanexe Void-Bound Voyager

    Thanks Silmaril.SE. All seems to be working but now I have a problem: When I face right the meteors go 70 degrees down, but when i face left the meteors go 70 up!
    How can i fix this?
     
  19. Taren

    Taren Orbital Explorer

    Don't use angleAdjust, use angle! That way you can use a total angle instead of a relative adjustment...
     
    Last edited: Mar 1, 2014
  20. Nightmanexe

    Nightmanexe Void-Bound Voyager

    Works better now. But it seems that there's another problem:

    Im using a first projectile that casts a second projectile (the meteorprojectile) at 70 degrees. So because of that all the meteors go from top left to down right (angle at 70) regardless of where im facing (left or right).

    This is the Gun:
    Code:
    {
      "itemName" : "BC_Meteor",
      "inventoryIcon" : "BC_Meteoricon.png",
      "description" : "description",
      "shortdescription" : " Meteor",
      "LargeImage" : "BC_Meteor.png",
      "dropCollision" : [-8.0, -3.0, 8.0, 3.0],
      "maxStack" : 1,
      "level" : 10,
      "rarity" : "Common",
      "inspectionKind" : "gun",
      "image" : "BC_Meteor.png",
      "recoilTime" : 0.1,
      "handPosition" : [0, 0],
      "firePosition" : [0, 200],
    
      "fireTime" : 0.35,
      "twoHanded" : false,
    
      "projectileType" : "Holeprojectile",
      "projectile" : {
      "power" : 100,
      "speed" : 100,
      "color" : [10, 255, 10]
      },
    
    This is the first projectile (that will summon the second projectile)
    Code:
    {
      "projectileName" : "Holeprojectile",
      "frames" : "dontneedimage.png",
      "animationCycle" : 0.15,
      "level" : 10,
      "frameNumber" : 1,
      "timeToLive" : 0.01,
      "physics" : "bullet",
      "flippable" : false,
      "damageKindImage" : "dontneedimage.png",
      "pointLight" : false,
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "Meteorprojectile",
          "inheritDamageFactor" : 5.0,
          "fuzzAngle" : 20,
          "angle" : -90
        },
            {
          "action" : "projectile",
          "type" : "Meteorprojectile",
          "inheritDamageFactor" : 5.0,
          "fuzzAngle" : 20,
          "angle" : -90
        },
            {
          "action" : "projectile",
          "type" : "Meteorprojectile",
          "inheritDamageFactor" : 5.0,
          "fuzzAngle" : 20,
          "angle" : -90
        }
      ],
      "power" : 5.0,
      "damageKind" : "default"
    }
    
    and this is the meteor projectile
    Code:
    {
      "projectileName" : "Meteorprojectile",
      "frames" : "Meteorprojectile.png",
      "animationCycle" : 0.15,
      "level" : 10,
      "frameNumber" : 1,
      "timeToLive" : 0.50,
      "physics" : "bullet",
      "flippable" : true,
      "speed" :120,
      "damageKindImage" : "Meteorprojectile.png",
      "pointLight" : false,
      "actionOnReap" : [
        {
          "action" : "config",
          "file" : "/projectiles/explosions/Impacteffect1/Impacteffect1.config"
        }
      ],
      "power" : 5.0,
      "damageKind" : "default"
    }
    
     
    followsmemphis likes this.

Share This Page