Modding Help EffectSource particles with status effects

Discussion in 'Starbound Modding' started by Evil Parrot, Feb 14, 2023.

  1. Evil Parrot

    Evil Parrot Scruffy Nerf-Herder

    Greetings!

    I'd like to ask for help and advice in a matter. I want to make a status effect for a custom species that would emit custom fire particles from their head, making it seem like their hairs are burning. Simple particles statuses won't do - when character crouches, all the particles are emitted from the same spot as if the character stood, and I have only found a way to bind emitter offset to the head via .sourceeffects files("location" : "mouth", as an example). And I have absolutely no idea as to how to apply sourceeffects for a character using a status effect and scripting. If you have any, and are willing to help, I'd gladly listen
     
  2. Rezetrx

    Rezetrx Void-Bound Voyager

    So if I understand correctly, you want to create a statuseffect that emits particles at the position of the head and make it adjust its position when crouching. (making sure I understand the problem correctly)

    If that is the case, you can do the following approach.
    In the lua of the status effect use mcontroller.crouching() to check if the affected target is crouching or not.
    If they are, adjust the OffsetRegion of the particleEmitter according to the new desired position (mind you that this is a Rect not a point, as such use [x1, y1, x2, y2] and not [x, y]). In case they are not crouching set the offsetRegion to a higher position.

    Like this:
    Code:
    function init()
        animator.setParticleEmitterActive("flames", true)
    end
    
    function update(dt)
        if mcontroller.crouching() then
           -- Lower Offset while crouching
            animator.setParticleEmitterOffsetRegion("flames", {-1, 0, 1, 0})
        else
           -- higher offset while not crouching
            animator.setParticleEmitterOffsetRegion("flames", {-1, 1, 1, 1})
        end
    end
    
    function uninit()
    end
    
    ( For those that don't know, in JSON you can use [x1, y1, x2, y2] but in Lua it must be like this {x1, y1, x2, y2} )
     
  3. Evil Parrot

    Evil Parrot Scruffy Nerf-Herder

    Oh, I didn't even know there is mcontroller.crouching condition. That helps, thank you! <3
     

Share This Page