Modding Help [Question] - Making a Tech that shoots a projectile?

Discussion in 'Starbound Modding' started by Exon, Dec 12, 2013.

  1. Exon

    Exon Subatomic Cosmonaut

    As the title implies, I want to know if making a tech that shoots a projectile on use is currently possible, and if yes, a quick explanation of how to do so would be super cool indeed!

    Thanks in advance!
     
  2. Exon

    Exon Subatomic Cosmonaut

    I'm guessing that's a no?
     
  3. TheWall

    TheWall Phantasmal Quasar

    You can use the world.spawnProjectile() function. There is a nice example of it in the vanilla mech tech on line 135
     
    Last edited: Dec 14, 2013
    SuperMandrew likes this.
  4. tifel100

    tifel100 Void-Bound Voyager

    This is it
    world.spawnProjectile(mechProjectile, tech.anchorPoint("frontGunFirePoint"), tech.parentEntityId(), {math.cos(aimAngle), math.sin(aimAngle)}, false, mechProjectileConfig)
    Do you know what the parameters are? Projectile, MousePoint?, ?, Angle?, Angle?, false?, Config?
    All I'm sure about is the first 1 being which projectile.

    Also, How come i Can't find the projectile in my files? Where is it stored? :mad:
     
    Last edited: Dec 14, 2013
  5. lonesurvivor

    lonesurvivor Big Damn Hero

    The parameters are
    Code:
    world.spawnProjectile("projectilename", spawn position, ID of the entity that spawned it, angle given by its cos and sin in a table, don't know, table of configuration parameters)
    The projectiles are usually found under assets/projectiles.
     
  6. tifel100

    tifel100 Void-Bound Voyager

    Managed to find where it was. Is there a way to spawn it at coords like. player + 2.5 X and +2.5 Y
     
  7. TheWall

    TheWall Phantasmal Quasar

    I believe that tech.position is the current location of the player. So using this as a base you can create a new position
    Code:
        local position = tech.position()
        position[1] = position[1] + 25
        position[2] = position[2] + 25
    
    and then use that as the spawn position

    Code:
    world.spawnProjectile("projecile", position, tech.parentEntityId(), {math.cos(aimAngle), math.sin(aimAngle)}, false,projectileConfig)
    If you want it to always have a static angle you will need to change the {math.cos(aimAngle), math.sin(aimAngle)} part to a static angle
     
  8. Exon

    Exon Subatomic Cosmonaut

    Alright, thanks!
     

Share This Page