Modding Help Preventing healing items for certain race

Discussion in 'Starbound Modding' started by draiza, Apr 19, 2022.

  1. draiza

    draiza Big Damn Hero

    Hello. I am making a custom race that heals when enemy gets hit. So, to balance this mechanic I want this race not be able to use usual healing items (there will be their individual expensive ones).

    So I have "lifesteal" status effect on race permanently and I need to check its existence on character in heal.lua, so if it exists effect.expire() activates. But I can't imagine how to do that. I tried using player.species() but it didn't work at all. As I learned from forum it's kinda bugged or smth.

    heal.lua edit:

    function init()
    animator.setParticleEmitterOffsetRegion("healing", mcontroller.boundBox())
    animator.setParticleEmitterEmissionRate("healing", config.getParameter("emissionRate", 3))
    animator.setParticleEmitterActive("healing", true)

    script.setUpdateDelta(5)

    self.healingRate = config.getParameter("healAmount", 30) / effect.duration()
    if //check for lifesteal effect?// then
    effect.expire()
    end
    end

    function update(dt)
    status.modifyResource("health", self.healingRate * dt)
    end

    function uninit()
    end
     
    Last edited: Apr 19, 2022
  2. draiza

    draiza Big Damn Hero

    Found a way to realise that. If anyone needs I will leave my code example. So there I am checking for effect named lifesteal in heal.lua from original game files. When lifesteal effect is on the player, heal effect instantly expires.
    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("healing", mcontroller.boundBox())
      animator.setParticleEmitterEmissionRate("healing", config.getParameter("emissionRate", 3))
      animator.setParticleEmitterActive("healing", true)
    
      script.setUpdateDelta(5)
    
      self.healingRate = config.getParameter("healAmount", 30) / effect.duration()
    end
    
    function update(dt)
      status.modifyResource("health", self.healingRate * dt)
    
      effects = status.activeUniqueStatusEffectSummary()
      if (#effects > 0) then
        for i=1, #effects do
          if (effects[i][1] == "lifesteal") then
            effect.expire()
          end
        end     
      end
    end
    
    function uninit()
    
    end
     

Share This Page