Modding Help Block Projectiles

Discussion in 'Starbound Modding' started by BitHorizon, Jul 9, 2014.

  1. BitHorizon

    BitHorizon Ketchup Robot

    I want to create a gun that shoots blocks of a certain kind. I see that things like Matter Block generators can do this. I see that the projectiles for the Matter Block generator do not use the frames file in the folder that it is in and do not reference the kind of block that it places on reap. Could someone explain this to me?
     
  2. prodamn

    prodamn Spaceman Spiff

    well, lua...

    the dungeonpod(matterblockgen) uses a lua script to spawn the matter blocks if destroyed.
    now.. this is a real weird process, but in the end, the block (matterblock) which is spawned is defined by the matterblockprojectile.projectile

    i had to search a bit till i found it.

    the object file...

    Code:
    {
      "objectName" : "dungeonpod",
      "rarity" : "Common",
      "objectType" : "wire",
    
      "category" : "--todo--",
      "price" : 0,
      "description" : "A material dispensing pod.",
      "shortdescription" : "Dispensing Pod",
      "race" : "generic",
    
      "apexDescription" : "This pod dispenses materials for crafting.",
      "avianDescription" : "Free crafting materials. Nice.",
      "floranDescription" : "Machine ssspit crafting items at Floran.",
      "glitchDescription" : "Wonder. A machine that gives materials for free!",
      "humanDescription" : "This is like a gashapon machine, but useful!",
      "hylotlDescription" : "A pod that supplies basic materials.",
    
      "inventoryIcon" : "dungeonpodicon.png",
      "lightColor" : [3, 47, 87],
    
      "orientations" : [
    
    
        {
          "imageLayers" : [ { "image" : "dungeonpod.png:default", "unlit" : true }, { "image" : "dungeonpod2.png:default" } ],
          "flipImages" : true,
          "imagePosition" : [-12, 0],
          "spaceScan" : 0.1,
          "anchors" : [ "bottom" ],
          "direction" : "left",
          "lightPosition" : [0, 3],
          "collision" : "platform"
        }
      ],
    
      "scripts" : [ "/objects/wired/tis1/tis1.lua" ],
      "scriptDelta" : 5,
    
      "animation" : "/objects/generic/dungeonpod/dungeonpod.animation",
      "animationParts" : {
        "tis1" : "dungeonpod.png"
      },
      "animationPosition" : [-12, 0],
    
      "useSounds" : [ "/sfx/objects/bardoor_open.wav" ],
    
      "inboundNodes" : [ ],
      "outboundNodes" : [ ],
    
      "breakDropOptions" : [ ],
    
      "projectileOptions" : [
        {
          "projectileType" : "matterblockprojectile2",
          "projectileParams" : { }
        }
      ]
    }
    


    well first the lua script


    Code:
    function init(args)
      if storage.initialized == nil then
        entity.setAnimationState("tis1State", "active")
        entity.setInteractive(true)
        entity.setColliding(false)
        storage.initialized = true
      end
    end
    
    function onInteraction(args)
      if isActive() then
          use(args)
      end
    end
    
    function hasCapability(capability)
      if capability == 'tis1' then
        return true
      else
        return false
      end
    end
    
    function isActive()
      return entity.animationState("tis1State") == "active"
    end
    
    function use(args)
      if isActive() then
        entity.setAnimationState("tis1State", "expire")
        entity.setInteractive(false)
        entity.playSound("useSounds")
    
        local projectile = entity.randomizeParameter("projectileOptions")
    
        world.spawnProjectile(projectile.projectileType, entity.position(), entity.id(), args.source, false, projectile.projectileParams)
      end
    end
    


    pretty much not saying anything about the block
    let's look at the projectile


    Code:
    {
      "projectileName" : "matterblockprojectile2",
      "physics" : "grenade",
      "bounces" : -1,
      "level" : 3,
      "timeToLive" : 0.001,
      "damageKindImage" : "icon.png",
      "frames" : "matterblockprojectile2.png",
      "animationCycle" : 0.5,
      "frameNumber" : 4,
      "speed" : 45,
      "actionOnReap" : [
        {
          "action" : "projectile",
          "type" : "dungeonpodexplosion",
          "fuzzAngle" : 0,
          "angleAdjust" : 0
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -20
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -40
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 60
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -80
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -100
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -120
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -140
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : -180
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 0
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 20
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 40
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 60
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 80
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 100
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 120
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 140
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 180
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 10
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 30
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 50
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 70
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 90
        },
        {
          "action" : "projectile",
          "type" : "matterblockprojectile",
          "fuzzAngle" : 0,
          "angleAdjust" : 10
        }
      ],
      "power" : 0,
      "piercing" : true,
      "damageKind" : "default",
      "damageType" : "ignoresdef",
      "damagePoly" : [ [-36, 0], [-24, -24], [0, -36], [24, -24], [36, 0], [24, 24], [0, 36], [-24, 24] ],
      "flippable" : true,
      "universalDamage" : true
    }
    


    wait... the projectile file is using another projectile ? what

    uhhh look at that! /projectiles/material/


    Code:
    {
      "projectileName" : "matterblockprojectile",
      "materialBlock" : 174,
      "physics" : "grenade",
      "level" : 3,
    
      // uses alternate animation path
      "frames" : "",
      "animationCycle" : 0,
      "frameNumber" : 0,
      "power" : 20,
    
      "speed" : 45,
      "fallSpeed" : 30, // this should be somekind of planet gravity scaled thing.
    
      "actionOnReap" : [
        {
          "action" : "placeMaterial"
        }
      ],
      "damageKind" : "slash"
    }
    


    it determains what block is spawned by an id..
    even actionOnReap!! "placeMaterial"

    i hope this helps you.
     

Share This Page