Modding Help Custom fuel air trail?

Discussion in 'Starbound Modding' started by Dekadrachm, Mar 17, 2017.

  1. Dekadrachm

    Dekadrachm Heliosphere

    Hello,

    I am working on a new alt ability that works like the fuel air trail ability. Essential it's the same thing with a few tweaks in effects, looks, and behavior. My issues is that upon ignition the default "fuelairtrailignition" projectile is used instead of my custom version.

    On the release of gas, the correct projectile is used because it is defined in the weapons altbility file. The ignition projectile doesn't appear to be defined at all within the altability lua file and the lua file for the fuelairtrail projectile.

    Any ideas on where I might find the projectile input for fuel ignition? It seems to be defined as ignition but what defines ignition and where can I find it to add/edit my own?

    ~Deka
     
    Last edited: Mar 17, 2017
  2. Dekadrachm

    Dekadrachm Heliosphere

    Code:
      -- ignite trail
      if self.lastProjectileId and world.entityExists(self.lastProjectileId) then
        world.callScriptedEntity(self.lastProjectileId, "ignite")
        self.lastProjectileId = nil
        animator.playSound("trailIgnite")
      end
    My issues most likely lies here, currently the lua fire for my custom alt ability is exactly the same. In this code it appears to replace the projectiles with the ignition projectile labeled as "ignite". I have not found a single place that defined the "ignite" parameter unless it is hard coded which doesn't seem likely.
     
  3. Dekadrachm

    Dekadrachm Heliosphere

    require "/scripts/util.lua"
    require "/scripts/vec2.lua"
    require "/items/active/weapons/weapon.lua"
    FuelAirTrail = WeaponAbility:new()
    function FuelAirTrail:init()
    self.cooldownTimer = 0
    end
    function FuelAirTrail:update(dt, fireMode, shiftHeld)
    WeaponAbility.update(self, dt, fireMode, shiftHeld)
    self.cooldownTimer = math.max(0, self.cooldownTimer - self.dt)
    if self.fireMode == "alt"
    and not self.weapon.currentAbility
    and self.cooldownTimer == 0
    and not status.resourceLocked("energy")
    and not world.lineTileCollision(mcontroller.position(), self:firePosition())
    and not world.liquidAt(self:firePosition()) then
    self:setState(self.fire)
    end
    end
    function FuelAirTrail:fire()
    self.weapon:setStance(self.stances.fire)
    self.weapon:updateAim()
    local pParams = copy(self.projectileParameters)
    pParams.power = pParams.power * root.evalFunction("weaponDamageLevelMultiplier", config.getParameter("level", 1))
    pParams.powerMultiplier = activeItem.ownerPowerMultiplier()
    self:spawnProjectile(self:firePosition(), pParams)
    animator.playSound("trailLoop", -1)
    -- lay trail
    while self.fireMode == "alt" and not status.resourceLocked("energy") do
    if not world.entityExists(self.lastProjectileId) then break end
    if world.liquidAt(self:firePosition()) then return true end

    local lastPosition = world.entityPosition(self.lastProjectileId)
    local delta = world.distance(self:firePosition(), lastPosition)
    if vec2.mag(delta) >= self.projectileFrequency then
    local nextPosition = vec2.add(lastPosition, vec2.mul(vec2.norm(delta), self.projectileFrequency))
    if world.pointTileCollision(nextPosition) then break end
    self:spawnProjectile(nextPosition, pParams)
    end
    coroutine.yield()
    end
    -- ignite trail
    if self.lastProjectileId and world.entityExists(self.lastProjectileId) then
    world.callScriptedEntity(self.lastProjectileId, "ignite")
    self.lastProjectileId = nil
    animator.playSound("trailIgnite")
    end
    animator.stopAllSounds("trailLoop")
    self.cooldownTimer = self.cooldown
    end
    function FuelAirTrail:reset()
    animator.stopAllSounds("trailLoop")
    end
    function FuelAirTrail:uninit(unequipped)
    self:reset()
    end
    function FuelAirTrail:firePosition()
    return vec2.add(mcontroller.position(), activeItem.handPosition(self.weapon.muzzleOffset))
    end
    function FuelAirTrail:aimVector(inaccuracy)
    local aimVector = vec2.rotate({1, 0}, self.weapon.aimAngle)
    aimVector[1] = aimVector[1] * self.weapon.aimDirection
    return aimVector
    end
    function FuelAirTrail:spawnProjectile(position, params)
    params.chainProjectile = self.lastProjectileId
    local projectileId = world.spawnProjectile(
    self.projectileType,
    position,
    activeItem.ownerEntityId(),
    self:aimVector(),
    false,
    params
    )
    if projectileId then
    status.overConsumeResource("energy", self.energyUsage)
    self.lastProjectileId = projectileId
    end
    return projectileId
    end

    Here is the full file, I'm not too lua savvy, but this is the same file for both the flamethrower alt ability and mine.
     
  4. Dekadrachm

    Dekadrachm Heliosphere

    Code:
    function init()
      self.chainProjectile = config.getParameter("chainProjectile")
      self.igniteAction = config.getParameter("igniteAction")
    end
    
    function update(dt)
      if self.chainTimer then
        self.chainTimer = math.max(0, self.chainTimer - dt)
        if self.chainTimer == 0 then
          if self.chainProjectile and world.entityExists(self.chainProjectile) then
            world.callScriptedEntity(self.chainProjectile, "ignite")
          end
          projectile.die()
        end
      end
    end
    
    function ignite()
      if projectile.timeToLive() < config.getParameter("cutoffTime") then return end
    
      if self.igniteAction then
        projectile.processAction(self.igniteAction)
      end
      self.chainTimer = config.getParameter("chainTime")
    end
    
    The projectiles lua and upon closer a look, it would appear my issue lies here, perhaps I need to find the config where the parameters are being set.

    But where is that config?
     
  5. Dekadrachm

    Dekadrachm Heliosphere

    Kawa answer this, [Closed]
     

Share This Page