Modding Help Where are these effects?

Discussion in 'Starbound Modding' started by Mackinz, Feb 28, 2015.

Thread Status:
Not open for further replies.
  1. Mackinz

    Mackinz The Waste of Time

    Dammit. You're right. I set the value to 0.5 and I'm still completely immune to melting.

    ****.

    Any idea how I could change the LUA so that I can reduce the damage without eliminating it entirely?

    Edit: Here's my coding at the moment:

    Code:
    {
      "name" : "occafireresist",
      "effectConfig" : {},
      "defaultDuration" : 10.0,
    
      "scripts" : [
        "occafireresist.lua"
      ]
    }
    Code:
    function init()
      effect.addStatModifierGroup({
        {stat = "lavaImmunity", amount = 0.5},
        {stat = "fireImmunity", amount = 0.5},
      })
    end
    
    function update(dt)
    end
    
    function uninit()
    end
    Edit 2: Brainstorming, since I'm obviously not even remotely good at LUA yet, I imagine I would have to isolate the damage from the "melting" and "burning" status effects and then find a way to reduce the damage from them. Am I close?

    Edit 3: Looking at what swatelite last posted, I misread what he was trying to say. So I might have to keep looking at what he suggested in order to better understand what the heck I need to be doing...[DOUBLEPOST=1425115163][/DOUBLEPOST]Okay, so here is my new game plan, based off of what @xxswatelitexx had mentioned earlier and that I had overlooked.

    I have changed my player.config.patch to this:

    Code:
    [
    { "op" : "add", "path" : "/species/-",
    "value" : "gallavoir"
    },
    {"op": "add", "path": "/statusControllerSettings/stats/occaFireArmor",
    "value": { "baseValue" : 1.0 }
    }
    ]
    (It's a race mod, so ignore that first bit)

    Next, I overwrote the vanilla burning.lua file:

    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("flames", mcontroller.boundBox())
      animator.setParticleEmitterActive("flames", true)
      effect.setParentDirectives("fade=BF3300=0.25")
      script.setUpdateDelta(5)
    
      self.tickDamagePercentage = 0.025
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
    end
    
    function update(dt)
      if effect.duration() and world.liquidAt({mcontroller.xPosition(), mcontroller.yPosition() - 1}) then
        effect.expire()
      end
    
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = math.floor(status.resourceMax("health") * self.tickDamagePercentage) + 1 * status.stat(occaFireArmor),
            damageSourceKind = "burning",
            sourceEntityId = entity.id()
          })
      end
    end
    
    function uninit()
    end
    Then I edited my status effect's LUA code to this:

    Code:
    function init()
      effect.addStatModifierGroup({
        {stat = "occaFireArmor", amount = 0.5},
      })
    end
    
    function update(dt)
    end
    
    function uninit()
    end
    So, when activated, it should cause the damage to be reduced by 50% as per his suggestion. I will be testing to see if this works. If it does, I will have to ask where I should similarly modify melting.lua. I also apologize to swatelite, because he really is a swell guy.

    Edit:

    So I tried it out. Got this error in the log.

    Code:
    [01:24:42.113] Error: Exception while invoking lua function 'update'. (LuaException) Error code 2, [string "/stats/effects/burning/burning.lua"]:23: (VariantException) stringify called on improper type null
      VariantException::VariantException(string)
      stringify(Variant)
      LuaBindings::StatusControllerCallbacks::stat(StatusController*, List<Variant, deque<Variant, allocator<Variant> > >)
      _Function_handler<Variant (List<Variant, deque<Variant, allocator<Variant> > >), _Bind<Variant (*(StatusController*, <1>))(StatusController*, List<Variant, deque<Variant, allocator<Variant> > >)> >::(_Any_data, List<Variant, deque<Variant, allocator<Variant> > >)
      __ZNSt17_Function_handlerIFN4Star3AnyIIbdNS0_6StringENS0_8LuaTableENS0_11LuaFunctionENS0_9LuaThreadENS0_11LuaUserDataEEEEPNS0_9LuaEngineEPKS7_jEZNS0_31registerVariantVariadicCallbackERNS0_12LuaCallbacksES2_St8functionIFNS0_7VariantENS0_4ListISG_St5dequeISG_SaISG_EEEEEEEUlS9_SB_jE_E9ERKSt9_Any_dataS9_SB_j
      LuaEngine::createVariadicFunction(function<Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> (LuaEngine*, Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData>*, unsigned int)>)::{lambda(lua_State*)#1}::operator()(lua_State*) [clone .isra.261]
      lua_getinfo
      28E85050
      22DBE3E8
      22DBE3A0
    
      StarException::StarException(String)
      LuaEngine::handleError(lua_State*, int)
      Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> LuaEngine::callFunction<initializer_list<Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> > >(int, initializer_list<Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> >)
      Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> LuaContext::invokePath<Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData> >(String, Any<bool, double, String, LuaTable, LuaFunction, LuaThread, LuaUserData>)
      Variant LuaVariantContext::invokePathVariant<float>(String, float)
      Maybe<Variant> LuaBaseComponent::invoke<float>(String, float)
      Maybe<Variant> LuaActorMovementComponent<LuaWorldComponent<LuaBaseComponent> >::update<float>(function<void ()>, float)
      StatusController::tickMaster()
      Player::tickMaster()
      _Function_handler<void (shared_ptr<Entity>), WorldClient::update()::{lambda(shared_ptr<Entity>)#3}>::(_Any_data, shared_ptr<Entity>)
      EntityMap::forAllEntities(function<void (shared_ptr<Entity>)>)
      WorldClient::update()
      UniverseClient::update()
      ClientApplication::updateRunning()
      ClientApplication::update()
      StarApplicationBase::run()
      _SDL_main
      _console_main
    What should I do? Also, I officially hate the auto-merging of "double posts", now. It's pretty difficult to point out that I am still testing.
     
    Last edited: Feb 28, 2015
  2. Mackinz

    Mackinz The Waste of Time

    Okay, so status update.

    Due to that last error I got, I decided to change the coding again to potentially fix the issue. This is how burning.lua looks now:

    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("flames", mcontroller.boundBox())
      animator.setParticleEmitterActive("flames", true)
      effect.setParentDirectives("fade=BF3300=0.25")
      script.setUpdateDelta(5)
    
      self.tickDamagePercentage = 0.025
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
    end
    
    function update(dt)
      if effect.duration() and world.liquidAt({mcontroller.xPosition(), mcontroller.yPosition() - 1}) then
        effect.expire()
      end
    
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = math.floor((status.resourceMax("health") * self.tickDamagePercentage) + 1) * status.stat(occaFireArmor),
            damageSourceKind = "burning",
            sourceEntityId = entity.id()
          })
      end
    end
    
    function uninit()
    end
    The change I made was an extra set of parantheses around the damage math. I was able to cause the burning status effect successfully, but it did no damage to me. Idk why. Did I do something completely wrong?
     
  3. The | Suit

    The | Suit Agent S. Forum Moderator

    you should check your log
    Probably this line should be
    status.stat("occaFireArmor")
     
  4. Mackinz

    Mackinz The Waste of Time

    Ah, good catch there. Will test again with the quote marks.

    Also, there was no error in the log (aside from completely irrelevant stuff like calling for the Tabula Rasa or a dungeon generation-related error).[DOUBLEPOST=1425117919][/DOUBLEPOST]OKAY. Check-in time.

    So, I got the status effect to affect me like normal. 3 damage per tick, like normal.

    But now, when I consume the consumable which changes "occaFireArmor", the damage increases from 3 to 5 damage per tick. How do I reduce it?[DOUBLEPOST=1425118010][/DOUBLEPOST]Paging @xxswatelitexx.
     
    Last edited: Feb 28, 2015
  5. The | Suit

    The | Suit Agent S. Forum Moderator

    Your math is wrong

    Code:
    math.floor(status.resourceMax("health") * self.tickDamagePercentage) + 1 * status.stat("occaFireArmor")
    This would multiply 1 with Firearmor
    Instead you need to modify the final value with fireArmor

    Edit:
    Forgot to mention effectsStatusModifier - adds or subtracts from the value.
    Doesn't replace the value.
     
    Last edited: Feb 28, 2015
  6. Mackinz

    Mackinz The Waste of Time

    Okay, so I did the change as you suggested, gave myself "burning", used the consumable, and the damage still went up. This time from 3 to 4.
     
  7. The | Suit

    The | Suit Agent S. Forum Moderator

    Ya I just made an edit to previous statement - forgot to mention
    what Effects Status Modifier does.


    Forgot to mention effectsStatusModifier - adds or subtracts from the value.
    Doesn't replace the value.
     
  8. Mackinz

    Mackinz The Waste of Time

    So, if I put in a negative value, would it subtract?
     
  9. The | Suit

    The | Suit Agent S. Forum Moderator

  10. Mackinz

    Mackinz The Waste of Time

    Okay, I tried using -0.5 as the value, and the damage stayed at 3 before and after using the consumable.

    So, I reverted my math. And it worked like I wanted it to. So... yeah. Now it reads "2" each tick, but it feels more like 1.5 per tick.

    Anyway, now that that is fixed, where should I edit melting.lua?

    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("flames", mcontroller.boundBox())
      animator.setParticleEmitterActive("flames", true)
      effect.setParentDirectives("fade=FF8800=0.2")
      script.setUpdateDelta(5)
    
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
      self.damage = 30
    
      status.applySelfDamageRequest({
          damageType = "IgnoresDef",
          damage = 30,
          sourceEntityId = entity.id()
        })
    end
    
    function update(dt)
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        self.damage = self.damage * 2
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = self.damage,
            sourceEntityId = entity.id()
          })
      end
    end
    
    function uninit()
      status.addEphemeralEffect("burning")
    end
     
  11. The | Suit

    The | Suit Agent S. Forum Moderator

    Basically its the same concept.
    You will have to work around the formula.

    Personally I place the formula outside and run the damage calculation applied as a variable without taking DT as a factor. As it isn't always constant
     
  12. Mackinz

    Mackinz The Waste of Time

    Well... does that mean it should be this?

    Code:
    function init()
      animator.setParticleEmitterOffsetRegion("flames", mcontroller.boundBox())
      animator.setParticleEmitterActive("flames", true)
      effect.setParentDirectives("fade=FF8800=0.2")
      script.setUpdateDelta(5)
    
      self.tickTime = 1.0
      self.tickTimer = self.tickTime
      self.damage = 30
    
      status.applySelfDamageRequest({
          damageType = "IgnoresDef",
          damage = 30,
          sourceEntityId = entity.id()
        })
    end
    
    function update(dt)
      self.tickTimer = self.tickTimer - dt
      if self.tickTimer <= 0 then
        self.tickTimer = self.tickTime
        self.damage = self.damage * 2
        status.applySelfDamageRequest({
            damageType = "IgnoresDef",
            damage = self.damage * status.stat("occaFireArmor"),
            sourceEntityId = entity.id()
          })
      end
    end
    
    function uninit()
      status.addEphemeralEffect("burning")
    end
    Because that seems strange.
     
  13. The | Suit

    The | Suit Agent S. Forum Moderator

    You are free to make the calculation how ever you want.
    Problem with DT is it isn't always constant as it should be.

    I was simply showing you how to use stat values to modify the damage value.


    Self tick timer = timer for script to activate.
    So if you want constant damage of say 5 per second.

    You can just make damage = 5. So every second 5 gets applied
    than do 5 * status.stat("FireArmor")

    which should make it 2.5 per second.
    ==
    You can make the formula as complex or as simple as you desire
     
  14. Mackinz

    Mackinz The Waste of Time

    Alrighty then!

    I successfully edited melting.lua to change its damage based on the value of the "occaFireArmor" value.

    Thanks so much for your help, @xxswatelitexx!

    Also, if you could close this thread in a few minutes that would be great.
     
Thread Status:
Not open for further replies.

Share This Page